@@ -409,53 +409,6 @@ Connection_dealloc(PyObject *self_)
409409 Py_TpFree (self_ );
410410}
411411
412- static PyObject *
413- Connection_new (PyTypeObject * type , PyObject * Py_UNUSED (args ), PyObject * Py_UNUSED (kwds ))
414- {
415- Connection * self ;
416-
417- self = (Connection * )type -> tp_alloc (type , 0 );
418- if (self != NULL )
419- {
420- self -> db = 0 ;
421- self -> dbmutex = 0 ;
422- self -> cursor_factory = Py_NewRef ((PyObject * )& APSWCursorType );
423- self -> dependents = PyList_New (0 );
424- self -> stmtcache = 0 ;
425- self -> fts5_api_cached = 0 ;
426- self -> busyhandler = 0 ;
427- self -> rollbackhook = 0 ;
428- self -> updatehook = 0 ;
429- self -> commithook = 0 ;
430- self -> walhook = 0 ;
431- self -> authorizer = 0 ;
432- self -> collationneeded = 0 ;
433- self -> exectrace = 0 ;
434- self -> rowtrace = 0 ;
435- self -> vfs = 0 ;
436- self -> savepointlevel = 0 ;
437- self -> open_flags = 0 ;
438- self -> open_vfs = 0 ;
439- self -> weakreflist = 0 ;
440- self -> tracehooks = PyMem_Malloc (sizeof (struct tracehook ) * 1 );
441- self -> tracehooks_count = 0 ;
442- if (self -> tracehooks )
443- {
444- self -> tracehooks [0 ].callback = 0 ;
445- self -> tracehooks [0 ].id = 0 ;
446- self -> tracehooks [0 ].mask = 0 ;
447- self -> tracehooks_count = 1 ;
448- }
449- self -> progresshandler = 0 ;
450- self -> progresshandler_count = 0 ;
451- CALL_TRACK_INIT (xConnect );
452- if (self -> dependents && self -> tracehooks )
453- return (PyObject * )self ;
454- }
455-
456- return NULL ;
457- }
458-
459412/** .. method:: __init__(filename: str, flags: int = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, vfs: Optional[str] = None, statementcachesize: int = 100)
460413
461414 Opens the named database. You can use ``:memory:`` to get a private temporary
@@ -506,6 +459,21 @@ Connection_init(PyObject *self_, PyObject *args, PyObject *kwargs)
506459 }
507460 flags |= SQLITE_OPEN_EXRESCODE ;
508461
462+ self -> cursor_factory = Py_NewRef ((PyObject * )& APSWCursorType );
463+ self -> tracehooks = PyMem_Malloc (sizeof (struct tracehook ) * 1 );
464+ if (!self -> tracehooks )
465+ return -1 ;
466+ self -> tracehooks [0 ].callback = 0 ;
467+ self -> tracehooks [0 ].id = 0 ;
468+ self -> tracehooks [0 ].mask = 0 ;
469+ self -> tracehooks_count = 1 ;
470+
471+ self -> dependents = PyList_New (0 );
472+ if (!self -> dependents )
473+ return -1 ;
474+
475+ CALL_TRACK_INIT (xConnect );
476+
509477 /* clamp cache size */
510478 if (statementcachesize < 0 )
511479 statementcachesize = 0 ;
@@ -5868,15 +5836,12 @@ static PyGetSetDef Connection_getseters[] = {
58685836 { "filename" , Connection_getmainfilename , NULL , Connection_filename_DOC , NULL },
58695837 { "filename_journal" , Connection_getjournalfilename , NULL , Connection_filename_journal_DOC , NULL },
58705838 { "filename_wal" , Connection_getwalfilename , NULL , Connection_filename_wal_DOC , NULL },
5871- { "cursor_factory" , Connection_get_cursor_factory , Connection_set_cursor_factory ,
5872- Connection_cursor_factory_DOC , NULL },
5839+ { "cursor_factory" , Connection_get_cursor_factory , Connection_set_cursor_factory , Connection_cursor_factory_DOC ,
5840+ NULL },
58735841 { "in_transaction" , Connection_get_in_transaction , NULL , Connection_in_transaction_DOC },
5874- { "exec_trace" , Connection_get_exec_trace_attr , Connection_set_exec_trace_attr ,
5875- Connection_exec_trace_DOC },
5876- { "row_trace" , Connection_get_row_trace_attr , Connection_set_row_trace_attr ,
5877- Connection_row_trace_DOC },
5878- { "authorizer" , Connection_get_authorizer_attr , Connection_set_authorizer_attr ,
5879- Connection_authorizer_DOC },
5842+ { "exec_trace" , Connection_get_exec_trace_attr , Connection_set_exec_trace_attr , Connection_exec_trace_DOC },
5843+ { "row_trace" , Connection_get_row_trace_attr , Connection_set_row_trace_attr , Connection_row_trace_DOC },
5844+ { "authorizer" , Connection_get_authorizer_attr , Connection_set_authorizer_attr , Connection_authorizer_DOC },
58805845 { "system_errno" , Connection_get_system_errno , NULL , Connection_system_errno_DOC },
58815846 { "is_interrupted" , Connection_is_interrupted , NULL , Connection_is_interrupted_DOC },
58825847#ifndef APSW_OMIT_OLD_NAMES
@@ -6120,7 +6085,7 @@ static PyTypeObject ConnectionType = {
61206085 .tp_methods = Connection_methods ,
61216086 .tp_members = Connection_members ,
61226087 .tp_getset = Connection_getseters ,
6123- .tp_init = ( initproc ) Connection_init ,
6124- .tp_new = Connection_new ,
6125- .tp_str = ( reprfunc ) Connection_tp_str ,
6088+ .tp_init = Connection_init ,
6089+ .tp_new = PyType_GenericNew ,
6090+ .tp_str = Connection_tp_str ,
61266091};
0 commit comments