Fix error handling of mysql_real_connect (#317)

Fixes #316
This commit is contained in:
INADA Naoki
2018-12-17 19:27:54 +09:00
committed by GitHub
parent ecf6d53aef
commit ea80e8f07a

View File

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