Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ea80e8f

Browse filesBrowse files
authored
Fix error handling of mysql_real_connect (PyMySQL#317)
Fixes PyMySQL#316
1 parent ecf6d53 commit ea80e8f
Copy full SHA for ea80e8f

File tree

Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed

‎MySQLdb/_mysql.c

Copy file name to clipboardExpand all lines: MySQLdb/_mysql.c
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ _mysql_ConnectionObject_Initialize(
446446

447447
Py_BEGIN_ALLOW_THREADS ;
448448
conn = mysql_init(&(self->connection));
449+
self->open = 1;
449450
if (connect_timeout) {
450451
unsigned int timeout = connect_timeout;
451452
mysql_options(&(self->connection), MYSQL_OPT_CONNECT_TIMEOUT,
@@ -496,6 +497,7 @@ _mysql_ConnectionObject_Initialize(
496497

497498
if (!conn) {
498499
_mysql_Exception(self);
500+
self->open = 0;
499501
return -1;
500502
}
501503

@@ -515,7 +517,6 @@ _mysql_ConnectionObject_Initialize(
515517
be done here. tp_dealloc still needs to call PyObject_GC_UnTrack(),
516518
however.
517519
*/
518-
self->open = 1;
519520
return 0;
520521
}
521522

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.