21
21
* 3. This notice may not be removed or altered from any source distribution.
22
22
*/
23
23
24
- #define NEEDS_PY_IDENTIFIER
25
-
26
24
#include "module.h"
27
25
#include "structmember.h" // PyMemberDef
28
26
#include "connection.h"
@@ -125,13 +123,12 @@ class _sqlite3.Connection "pysqlite_Connection *" "clinic_state()->ConnectionTyp
125
123
[clinic start generated code]*/
126
124
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=67369db2faf80891]*/
127
125
128
- _Py_IDENTIFIER (cursor );
129
-
130
126
static void _pysqlite_drop_unused_cursor_references (pysqlite_Connection * self );
131
127
static void free_callback_context (callback_context * ctx );
132
128
static void set_callback_context (callback_context * * ctx_pp ,
133
129
callback_context * ctx );
134
130
static void connection_close (pysqlite_Connection * self );
131
+ PyObject * _pysqlite_query_execute (pysqlite_Cursor * , int , PyObject * , PyObject * );
135
132
136
133
static PyObject *
137
134
new_statement_cache (pysqlite_Connection * self , pysqlite_state * state ,
@@ -782,7 +779,6 @@ final_callback(sqlite3_context *context)
782
779
783
780
PyObject * function_result ;
784
781
PyObject * * aggregate_instance ;
785
- _Py_IDENTIFIER (finalize );
786
782
int ok ;
787
783
PyObject * exception , * value , * tb ;
788
784
@@ -801,8 +797,10 @@ final_callback(sqlite3_context *context)
801
797
/* Keep the exception (if any) of the last call to step() */
802
798
PyErr_Fetch (& exception , & value , & tb );
803
799
804
- function_result = _PyObject_CallMethodIdNoArgs (* aggregate_instance , & PyId_finalize );
805
-
800
+ callback_context * ctx = (callback_context * )sqlite3_user_data (context );
801
+ assert (ctx != NULL );
802
+ function_result = PyObject_CallMethodNoArgs (* aggregate_instance ,
803
+ ctx -> state -> str_finalize );
806
804
Py_DECREF (* aggregate_instance );
807
805
808
806
ok = 0 ;
@@ -1432,16 +1430,14 @@ pysqlite_connection_execute_impl(pysqlite_Connection *self, PyObject *sql,
1432
1430
PyObject * parameters )
1433
1431
/*[clinic end generated code: output=5be05ae01ee17ee4 input=fbd17c75c7140271]*/
1434
1432
{
1435
- _Py_IDENTIFIER (execute );
1436
- PyObject * cursor = 0 ;
1437
1433
PyObject * result = 0 ;
1438
1434
1439
- cursor = _PyObject_CallMethodIdNoArgs (( PyObject * ) self , & PyId_cursor );
1435
+ PyObject * cursor = pysqlite_connection_cursor_impl ( self , NULL );
1440
1436
if (!cursor ) {
1441
1437
goto error ;
1442
1438
}
1443
1439
1444
- result = _PyObject_CallMethodIdObjArgs ( cursor , & PyId_execute , sql , parameters , NULL );
1440
+ result = _pysqlite_query_execute (( pysqlite_Cursor * ) cursor , 0 , sql , parameters );
1445
1441
if (!result ) {
1446
1442
Py_CLEAR (cursor );
1447
1443
}
@@ -1467,17 +1463,14 @@ pysqlite_connection_executemany_impl(pysqlite_Connection *self,
1467
1463
PyObject * sql , PyObject * parameters )
1468
1464
/*[clinic end generated code: output=776cd2fd20bfe71f input=4feab80659ffc82b]*/
1469
1465
{
1470
- _Py_IDENTIFIER (executemany );
1471
- PyObject * cursor = 0 ;
1472
1466
PyObject * result = 0 ;
1473
1467
1474
- cursor = _PyObject_CallMethodIdNoArgs (( PyObject * ) self , & PyId_cursor );
1468
+ PyObject * cursor = pysqlite_connection_cursor_impl ( self , NULL );
1475
1469
if (!cursor ) {
1476
1470
goto error ;
1477
1471
}
1478
1472
1479
- result = _PyObject_CallMethodIdObjArgs (cursor , & PyId_executemany , sql ,
1480
- parameters , NULL );
1473
+ result = _pysqlite_query_execute ((pysqlite_Cursor * )cursor , 1 , sql , parameters );
1481
1474
if (!result ) {
1482
1475
Py_CLEAR (cursor );
1483
1476
}
@@ -1502,17 +1495,15 @@ pysqlite_connection_executescript(pysqlite_Connection *self,
1502
1495
PyObject * script_obj )
1503
1496
/*[clinic end generated code: output=4c4f9d77aa0ae37d input=b27ae5c24ffb8b43]*/
1504
1497
{
1505
- _Py_IDENTIFIER (executescript );
1506
- PyObject * cursor = 0 ;
1507
1498
PyObject * result = 0 ;
1508
1499
1509
- cursor = _PyObject_CallMethodIdNoArgs (( PyObject * ) self , & PyId_cursor );
1500
+ PyObject * cursor = pysqlite_connection_cursor_impl ( self , NULL );
1510
1501
if (!cursor ) {
1511
1502
goto error ;
1512
1503
}
1513
1504
1514
- result = _PyObject_CallMethodIdObjArgs ( cursor , & PyId_executescript ,
1515
- script_obj , NULL );
1505
+ PyObject * meth = self -> state -> str_executescript ; // borrowed ref.
1506
+ result = PyObject_CallMethodObjArgs ( cursor , meth , script_obj , NULL );
1516
1507
if (!result ) {
1517
1508
Py_CLEAR (cursor );
1518
1509
}
@@ -1620,7 +1611,6 @@ static PyObject *
1620
1611
pysqlite_connection_iterdump_impl (pysqlite_Connection * self )
1621
1612
/*[clinic end generated code: output=586997aaf9808768 input=53bc907cb5eedb85]*/
1622
1613
{
1623
- _Py_IDENTIFIER (_iterdump );
1624
1614
PyObject * retval = NULL ;
1625
1615
PyObject * module = NULL ;
1626
1616
PyObject * module_dict ;
@@ -1640,7 +1630,12 @@ pysqlite_connection_iterdump_impl(pysqlite_Connection *self)
1640
1630
goto finally ;
1641
1631
}
1642
1632
1643
- pyfn_iterdump = _PyDict_GetItemIdWithError (module_dict , & PyId__iterdump );
1633
+ PyObject * meth = PyUnicode_InternFromString ("_iterdump" );
1634
+ if (meth == NULL ) {
1635
+ goto finally ;
1636
+ }
1637
+ pyfn_iterdump = PyDict_GetItemWithError (module_dict , meth );
1638
+ Py_DECREF (meth );
1644
1639
if (!pyfn_iterdump ) {
1645
1640
if (!PyErr_Occurred ()) {
1646
1641
PyErr_SetString (self -> OperationalError ,
0 commit comments