diff --git a/MySQLdb/_mysql.c b/MySQLdb/_mysql.c index 3c84627..f12231b 100644 --- a/MySQLdb/_mysql.c +++ b/MySQLdb/_mysql.c @@ -444,8 +444,12 @@ _mysql_ConnectionObject_Initialize( _stringsuck(cipher, value, ssl); } - Py_BEGIN_ALLOW_THREADS ; conn = mysql_init(&(self->connection)); + if (!conn) { + PyErr_SetNone(PyExc_MemoryError); + return -1; + } + Py_BEGIN_ALLOW_THREADS ; self->open = 1; if (connect_timeout) { unsigned int timeout = connect_timeout; @@ -497,7 +501,6 @@ _mysql_ConnectionObject_Initialize( if (!conn) { _mysql_Exception(self); - self->open = 0; return -1; }