2121 * 3. This notice may not be removed or altered from any source distribution. 
2222 */ 
2323
24- #define  NEEDS_PY_IDENTIFIER 
25- 
2624#include  "module.h" 
2725#include  "structmember.h"          // PyMemberDef 
2826#include  "connection.h" 
@@ -125,13 +123,12 @@ class _sqlite3.Connection "pysqlite_Connection *" "clinic_state()->ConnectionTyp
125123[clinic start generated code]*/ 
126124/*[clinic end generated code: output=da39a3ee5e6b4b0d input=67369db2faf80891]*/ 
127125
128- _Py_IDENTIFIER (cursor );
129- 
130126static  void  _pysqlite_drop_unused_cursor_references (pysqlite_Connection *  self );
131127static  void  free_callback_context (callback_context  * ctx );
132128static  void  set_callback_context (callback_context  * * ctx_pp ,
133129                                 callback_context  * ctx );
134130static  void  connection_close (pysqlite_Connection  * self );
131+ PyObject  * _pysqlite_query_execute (pysqlite_Cursor  * , int , PyObject  * , PyObject  * );
135132
136133static  PyObject  * 
137134new_statement_cache (pysqlite_Connection  * self , pysqlite_state  * state ,
@@ -782,7 +779,6 @@ final_callback(sqlite3_context *context)
782779
783780    PyObject *  function_result ;
784781    PyObject * *  aggregate_instance ;
785-     _Py_IDENTIFIER (finalize );
786782    int  ok ;
787783    PyObject  * exception , * value , * tb ;
788784
@@ -801,8 +797,10 @@ final_callback(sqlite3_context *context)
801797    /* Keep the exception (if any) of the last call to step() */ 
802798    PyErr_Fetch (& exception , & value , & tb );
803799
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 );
806804    Py_DECREF (* aggregate_instance );
807805
808806    ok  =  0 ;
@@ -1432,16 +1430,14 @@ pysqlite_connection_execute_impl(pysqlite_Connection *self, PyObject *sql,
14321430                                 PyObject  * parameters )
14331431/*[clinic end generated code: output=5be05ae01ee17ee4 input=fbd17c75c7140271]*/ 
14341432{
1435-     _Py_IDENTIFIER (execute );
1436-     PyObject *  cursor  =  0 ;
14371433    PyObject *  result  =  0 ;
14381434
1439-     cursor  =  _PyObject_CallMethodIdNoArgs (( PyObject * ) self , & PyId_cursor );
1435+     PyObject   * cursor  =  pysqlite_connection_cursor_impl ( self , NULL );
14401436    if  (!cursor ) {
14411437        goto error ;
14421438    }
14431439
1444-     result  =  _PyObject_CallMethodIdObjArgs ( cursor , & PyId_execute , sql , parameters ,  NULL );
1440+     result  =  _pysqlite_query_execute (( pysqlite_Cursor   * ) cursor , 0 , sql , parameters );
14451441    if  (!result ) {
14461442        Py_CLEAR (cursor );
14471443    }
@@ -1467,17 +1463,14 @@ pysqlite_connection_executemany_impl(pysqlite_Connection *self,
14671463                                     PyObject  * sql , PyObject  * parameters )
14681464/*[clinic end generated code: output=776cd2fd20bfe71f input=4feab80659ffc82b]*/ 
14691465{
1470-     _Py_IDENTIFIER (executemany );
1471-     PyObject *  cursor  =  0 ;
14721466    PyObject *  result  =  0 ;
14731467
1474-     cursor  =  _PyObject_CallMethodIdNoArgs (( PyObject * ) self , & PyId_cursor );
1468+     PyObject   * cursor  =  pysqlite_connection_cursor_impl ( self , NULL );
14751469    if  (!cursor ) {
14761470        goto error ;
14771471    }
14781472
1479-     result  =  _PyObject_CallMethodIdObjArgs (cursor , & PyId_executemany , sql ,
1480-                                            parameters , NULL );
1473+     result  =  _pysqlite_query_execute ((pysqlite_Cursor  * )cursor , 1 , sql , parameters );
14811474    if  (!result ) {
14821475        Py_CLEAR (cursor );
14831476    }
@@ -1502,17 +1495,15 @@ pysqlite_connection_executescript(pysqlite_Connection *self,
15021495                                  PyObject  * script_obj )
15031496/*[clinic end generated code: output=4c4f9d77aa0ae37d input=b27ae5c24ffb8b43]*/ 
15041497{
1505-     _Py_IDENTIFIER (executescript );
1506-     PyObject *  cursor  =  0 ;
15071498    PyObject *  result  =  0 ;
15081499
1509-     cursor  =  _PyObject_CallMethodIdNoArgs (( PyObject * ) self , & PyId_cursor );
1500+     PyObject   * cursor  =  pysqlite_connection_cursor_impl ( self , NULL );
15101501    if  (!cursor ) {
15111502        goto error ;
15121503    }
15131504
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 );
15161507    if  (!result ) {
15171508        Py_CLEAR (cursor );
15181509    }
@@ -1620,7 +1611,6 @@ static PyObject *
16201611pysqlite_connection_iterdump_impl (pysqlite_Connection  * self )
16211612/*[clinic end generated code: output=586997aaf9808768 input=53bc907cb5eedb85]*/ 
16221613{
1623-     _Py_IDENTIFIER (_iterdump );
16241614    PyObject *  retval  =  NULL ;
16251615    PyObject *  module  =  NULL ;
16261616    PyObject *  module_dict ;
@@ -1640,7 +1630,12 @@ pysqlite_connection_iterdump_impl(pysqlite_Connection *self)
16401630        goto finally ;
16411631    }
16421632
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 );
16441639    if  (!pyfn_iterdump ) {
16451640        if  (!PyErr_Occurred ()) {
16461641            PyErr_SetString (self -> OperationalError ,
0 commit comments