Skip to content

Commit 3ec5ded

Browse files
committed
Return NULLs explicitly in the module initialization
1 parent 4d82d69 commit 3ec5ded

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Modules/_librabbitmq/connection.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2264,7 +2264,11 @@ PYRABBITMQ_MOD_INIT(_librabbitmq)
22642264
PyObject *module, *socket_module;
22652265

22662266
if (PyType_Ready(&PyRabbitMQ_ConnectionType) < 0) {
2267+
#if PY_MAJOR_VERSION >= 3
2268+
return NULL;
2269+
#else
22672270
return;
2271+
#endif
22682272
}
22692273

22702274
#if PY_MAJOR_VERSION >= 3
@@ -2275,13 +2279,22 @@ PYRABBITMQ_MOD_INIT(_librabbitmq)
22752279
#endif
22762280

22772281
if (module == NULL) {
2282+
#if PY_MAJOR_VERSION >= 3
2283+
return NULL;
2284+
#else
22782285
return;
2286+
#endif
22792287
}
22802288

22812289
/* Get socket.error */
22822290
socket_module = PyImport_ImportModule("socket");
2283-
if (!socket_module)
2291+
if (!socket_module) {
2292+
#if PY_MAJOR_VERSION >= 3
2293+
return NULL;
2294+
#else
22842295
return;
2296+
#endif
2297+
}
22852298
PyRabbitMQ_socket_timeout = PyObject_GetAttrString(socket_module, "timeout");
22862299
Py_XDECREF(socket_module);
22872300

0 commit comments

Comments
 (0)