Skip to content

Commit 91e8618

Browse files
committed
Raise import error on module import failure to avoid segfault
1 parent 4b85234 commit 91e8618

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

confluent_kafka/src/confluent_kafka.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,10 +1952,10 @@ PyObject *cfl_PyObject_lookup (const char *modulename, const char *typename) {
19521952
PyObject *module = PyImport_ImportModule(modulename);
19531953
PyObject *obj;
19541954

1955-
if (!modulename) {
1956-
PyErr_Format(PyExc_TypeError,
1957-
"Module %s not found when looking up %s.%s",
1958-
modulename, modulename, typename);
1955+
if (!module) {
1956+
PyErr_Format(PyExc_ImportError,
1957+
"Module not found when looking up %s.%s",
1958+
modulename, typename);
19591959
return NULL;
19601960
}
19611961

0 commit comments

Comments
 (0)