Skip to content

Commit

Permalink
Fix error handling of mysql_real_connect (#317)
Browse files Browse the repository at this point in the history
Fixes #316
  • Loading branch information
methane committed Dec 17, 2018
1 parent ecf6d53 commit ea80e8f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion MySQLdb/_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -496,6 +497,7 @@ _mysql_ConnectionObject_Initialize(

if (!conn) {
_mysql_Exception(self);
self->open = 0;
return -1;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit ea80e8f

Please sign in to comment.