@@ -63,7 +63,7 @@ MySQL_connected(MySQL *self);
63
63
}
64
64
65
65
#define IS_CONNECTED (cnx ) \
66
- if ((PyObject *)MySQL_connected( cnx) == Py_False) { \
66
+ if (! cnx->connected) { \
67
67
raise_with_session(&cnx->session, MySQLInterfaceError); \
68
68
return 0; \
69
69
}
313
313
MySQL_dealloc (MySQL * self )
314
314
{
315
315
if (self ) {
316
- MySQL_free_result (self );
316
+ Py_XDECREF ( MySQL_free_result (self ) );
317
317
mysql_close (& self -> session );
318
318
319
319
Py_DECREF (self -> charset_name );
@@ -503,7 +503,7 @@ MySQL_free_result(MySQL *self)
503
503
Py_END_ALLOW_THREADS
504
504
}
505
505
506
- MySQL_reset_result (self );
506
+ Py_XDECREF ( MySQL_reset_result (self ) );
507
507
508
508
Py_RETURN_NONE ;
509
509
}
@@ -536,7 +536,7 @@ MySQL_consume_result(MySQL *self)
536
536
Py_END_ALLOW_THREADS
537
537
}
538
538
539
- MySQL_free_result (self );
539
+ Py_XDECREF ( MySQL_free_result (self ) );
540
540
541
541
Py_RETURN_NONE ;
542
542
}
@@ -781,8 +781,6 @@ MySQL_st_warning_count(MySQL *self)
781
781
782
782
Return whether the MySQL instance is connected or not.
783
783
784
- This function uses the mysql_ping() C API function.
785
-
786
784
@param self MySQL instance
787
785
788
786
@return Boolean Object Py_True or Py_False
@@ -795,7 +793,6 @@ MySQL_connected(MySQL *self)
795
793
Py_RETURN_FALSE ;
796
794
}
797
795
798
- self -> connected = 1 ;
799
796
Py_RETURN_TRUE ;
800
797
}
801
798
@@ -1280,9 +1277,9 @@ MySQL_connect(MySQL *self, PyObject *args, PyObject *kwds)
1280
1277
PyObject * err_msg = PyUnicode_FromString ("sha256_password requires SSL" );
1281
1278
PyObject * err_obj = NULL ;
1282
1279
err_obj = PyObject_CallFunctionObjArgs (exc_type , err_msg , NULL );
1283
- PyObject_SetAttr (err_obj , PyUnicode_FromString ( "sqlstate" ) , Py_None );
1284
- PyObject_SetAttr (err_obj , PyUnicode_FromString ( "errno" ) , err_no );
1285
- PyObject_SetAttr (err_obj , PyUnicode_FromString ( "msg" ) , err_msg );
1280
+ PyObject_SetAttrString (err_obj , "sqlstate" , Py_None );
1281
+ PyObject_SetAttrString (err_obj , "errno" , err_no );
1282
+ PyObject_SetAttrString (err_obj , "msg" , err_msg );
1286
1283
PyErr_SetObject (exc_type , err_obj );
1287
1284
Py_XDECREF (exc_type );
1288
1285
Py_XDECREF (err_no );
@@ -2185,7 +2182,7 @@ MySQL_query(MySQL *self, PyObject *args, PyObject *kwds)
2185
2182
}
2186
2183
2187
2184
if ((& self -> session )-> field_count == 0 ) {
2188
- MySQL_reset_result (self );
2185
+ Py_XDECREF ( MySQL_reset_result (self ) );
2189
2186
self -> have_result_set = Py_False ;
2190
2187
Py_RETURN_TRUE ;
2191
2188
}
@@ -2494,7 +2491,7 @@ MySQL_next_result(MySQL *self)
2494
2491
Py_RETURN_FALSE ;
2495
2492
}
2496
2493
2497
- MySQL_free_result (self );
2494
+ Py_XDECREF ( MySQL_free_result (self ) );
2498
2495
// We had a result before, we check if we can get next one
2499
2496
Py_BEGIN_ALLOW_THREADS
2500
2497
have_more = mysql_next_result (& self -> session );
@@ -2505,7 +2502,7 @@ MySQL_next_result(MySQL *self)
2505
2502
return NULL ;
2506
2503
}
2507
2504
2508
- MySQL_free_result (self );
2505
+ Py_XDECREF ( MySQL_free_result (self ) );
2509
2506
return MySQL_handle_result (self );
2510
2507
}
2511
2508
0 commit comments