diff --git a/psycopg/psycopgmodule.c b/psycopg/psycopgmodule.c index 61e2de57..be6e3343 100644 --- a/psycopg/psycopgmodule.c +++ b/psycopg/psycopgmodule.c @@ -181,13 +181,16 @@ psyco_register_type(PyObject *self, PyObject *args) static void psyco_libcrypto_threads_init(void) { + PyObject *m; + /* importing the ssl module sets up Python's libcrypto callbacks */ - if (PyImport_ImportModule("ssl") != NULL) { + if ((m = PyImport_ImportModule("ssl"))) { /* disable libcrypto setup in libpq, so it won't stomp on the callbacks that have already been set up */ #if PG_VERSION_HEX >= 0x080400 PQinitOpenSSL(1, 0); #endif + Py_DECREF(m); } else { /* might mean that Python has been compiled without OpenSSL support,