return -1;
}
- if (PyModule_AddObject(module, "adapters", psyco_adapters) < 0) {
- Py_DECREF(psyco_adapters);
- return -1;
- }
+ int res = PyModule_AddObjectRef(module, "adapters", psyco_adapters);
+ Py_DECREF(psyco_adapters);
- return 0;
+ return res;
}
return pysqlite_microprotocols_adapt(obj, proto, alt);
}
-static void converters_init(PyObject* module)
+static int converters_init(PyObject* module)
{
_pysqlite_converters = PyDict_New();
if (!_pysqlite_converters) {
- return;
+ return -1;
}
- if (PyModule_AddObject(module, "converters", _pysqlite_converters) < 0) {
- Py_DECREF(_pysqlite_converters);
- }
- return;
+ int res = PyModule_AddObjectRef(module, "converters", _pysqlite_converters);
+ Py_DECREF(_pysqlite_converters);
+
+ return res;
}
static PyMethodDef module_methods[] = {
if (!exc) { \
goto error; \
} \
- if (PyModule_AddObject(module, name, exc) < 0) { \
- Py_DECREF(exc); \
+ int res = PyModule_AddObjectRef(module, name, exc); \
+ Py_DECREF(exc); \
+ if (res < 0) { \
goto error; \
} \
} while (0)
non-ASCII data and bytestrings to be returned for ASCII data.
Now OptimizedUnicode is an alias for str, so it has no
effect. */
- Py_INCREF((PyObject*)&PyUnicode_Type);
- if (PyModule_AddObject(module, "OptimizedUnicode", (PyObject*)&PyUnicode_Type) < 0) {
- Py_DECREF((PyObject*)&PyUnicode_Type);
+ if (PyModule_AddObjectRef(module, "OptimizedUnicode", (PyObject*)&PyUnicode_Type) < 0) {
goto error;
}
}
/* initialize the default converters */
- converters_init(module);
+ if (converters_init(module) < 0) {
+ goto error;
+ }
error:
if (PyErr_Occurred())