mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-40737: Fix possible reference leak for sqlite3 initialization (GH-20323)
This commit is contained in:
parent
be63019ed7
commit
5eb45d7d4e
2 changed files with 13 additions and 8 deletions
|
@ -0,0 +1 @@
|
||||||
|
Fix possible reference leak for :mod:`sqlite3` initialization.
|
|
@ -346,6 +346,14 @@ static struct PyModuleDef _sqlite3module = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define ADD_TYPE(module, type) \
|
||||||
|
do { \
|
||||||
|
if (PyModule_AddType(module, &type) < 0) { \
|
||||||
|
Py_DECREF(module); \
|
||||||
|
return NULL; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
PyMODINIT_FUNC PyInit__sqlite3(void)
|
PyMODINIT_FUNC PyInit__sqlite3(void)
|
||||||
{
|
{
|
||||||
PyObject *module, *dict;
|
PyObject *module, *dict;
|
||||||
|
@ -366,14 +374,10 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(&pysqlite_ConnectionType);
|
ADD_TYPE(module, pysqlite_ConnectionType);
|
||||||
PyModule_AddObject(module, "Connection", (PyObject*) &pysqlite_ConnectionType);
|
ADD_TYPE(module, pysqlite_CursorType);
|
||||||
Py_INCREF(&pysqlite_CursorType);
|
ADD_TYPE(module, pysqlite_PrepareProtocolType);
|
||||||
PyModule_AddObject(module, "Cursor", (PyObject*) &pysqlite_CursorType);
|
ADD_TYPE(module, pysqlite_RowType);
|
||||||
Py_INCREF(&pysqlite_PrepareProtocolType);
|
|
||||||
PyModule_AddObject(module, "PrepareProtocol", (PyObject*) &pysqlite_PrepareProtocolType);
|
|
||||||
Py_INCREF(&pysqlite_RowType);
|
|
||||||
PyModule_AddObject(module, "Row", (PyObject*) &pysqlite_RowType);
|
|
||||||
|
|
||||||
if (!(dict = PyModule_GetDict(module))) {
|
if (!(dict = PyModule_GetDict(module))) {
|
||||||
goto error;
|
goto error;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue