@@ -263,17 +263,17 @@ pysqlite_adapt_impl(PyObject *module, PyObject *obj, PyObject *proto,
263
263
return pysqlite_microprotocols_adapt (obj , proto , alt );
264
264
}
265
265
266
- static void converters_init (PyObject * module )
266
+ static int converters_init (PyObject * module )
267
267
{
268
268
_pysqlite_converters = PyDict_New ();
269
269
if (!_pysqlite_converters ) {
270
- return ;
270
+ return -1 ;
271
271
}
272
272
273
- if ( PyModule_AddObject ( module , "converters" , _pysqlite_converters ) < 0 ) {
274
- Py_DECREF (_pysqlite_converters );
275
- }
276
- return ;
273
+ int res = PyModule_AddObjectRef ( module , "converters" , _pysqlite_converters );
274
+ Py_DECREF (_pysqlite_converters );
275
+
276
+ return res ;
277
277
}
278
278
279
279
static PyMethodDef module_methods [] = {
@@ -361,8 +361,9 @@ do { \
361
361
if (!exc) { \
362
362
goto error; \
363
363
} \
364
- if (PyModule_AddObject(module, name, exc) < 0) { \
365
- Py_DECREF(exc); \
364
+ int res = PyModule_AddObjectRef(module, name, exc); \
365
+ Py_DECREF(exc); \
366
+ if (res < 0) { \
366
367
goto error; \
367
368
} \
368
369
} while (0)
@@ -416,9 +417,7 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
416
417
non-ASCII data and bytestrings to be returned for ASCII data.
417
418
Now OptimizedUnicode is an alias for str, so it has no
418
419
effect. */
419
- Py_INCREF ((PyObject * )& PyUnicode_Type );
420
- if (PyModule_AddObject (module , "OptimizedUnicode" , (PyObject * )& PyUnicode_Type ) < 0 ) {
421
- Py_DECREF ((PyObject * )& PyUnicode_Type );
420
+ if (PyModule_AddObjectRef (module , "OptimizedUnicode" , (PyObject * )& PyUnicode_Type ) < 0 ) {
422
421
goto error ;
423
422
}
424
423
@@ -441,7 +440,9 @@ PyMODINIT_FUNC PyInit__sqlite3(void)
441
440
}
442
441
443
442
/* initialize the default converters */
444
- converters_init (module );
443
+ if (converters_init (module ) < 0 ) {
444
+ goto error ;
445
+ }
445
446
446
447
error :
447
448
if (PyErr_Occurred ())
0 commit comments