Skip to content

Commit

Permalink
Raise import error on module import failure to avoid segfault
Browse files Browse the repository at this point in the history
  • Loading branch information
overstre committed Feb 26, 2020
1 parent 4b85234 commit 91e8618
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions confluent_kafka/src/confluent_kafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -1952,10 +1952,10 @@ PyObject *cfl_PyObject_lookup (const char *modulename, const char *typename) {
PyObject *module = PyImport_ImportModule(modulename);
PyObject *obj;

if (!modulename) {
PyErr_Format(PyExc_TypeError,
"Module %s not found when looking up %s.%s",
modulename, modulename, typename);
if (!module) {
PyErr_Format(PyExc_ImportError,
"Module not found when looking up %s.%s",
modulename, typename);
return NULL;
}

Expand Down

0 comments on commit 91e8618

Please sign in to comment.