diff --git a/MySQLdb/_mysql.c b/MySQLdb/_mysql.c index 5ae6652..cf4566d 100644 --- a/MySQLdb/_mysql.c +++ b/MySQLdb/_mysql.c @@ -446,6 +446,7 @@ _mysql_ConnectionObject_Initialize( Py_BEGIN_ALLOW_THREADS ; conn = mysql_init(&(self->connection)); + self->open = 1; if (connect_timeout) { unsigned int timeout = connect_timeout; mysql_options(&(self->connection), MYSQL_OPT_CONNECT_TIMEOUT, @@ -496,6 +497,7 @@ _mysql_ConnectionObject_Initialize( if (!conn) { _mysql_Exception(self); + self->open = 0; return -1; } @@ -515,7 +517,6 @@ _mysql_ConnectionObject_Initialize( be done here. tp_dealloc still needs to call PyObject_GC_UnTrack(), however. */ - self->open = 1; return 0; }