diff options
Diffstat (limited to 'contrib/tools/python3/Modules/_sqlite/microprotocols.c')
| -rw-r--r-- | contrib/tools/python3/Modules/_sqlite/microprotocols.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/contrib/tools/python3/Modules/_sqlite/microprotocols.c b/contrib/tools/python3/Modules/_sqlite/microprotocols.c index 148220d0f91..f77458d94a8 100644 --- a/contrib/tools/python3/Modules/_sqlite/microprotocols.c +++ b/contrib/tools/python3/Modules/_sqlite/microprotocols.c @@ -85,20 +85,19 @@ pysqlite_microprotocols_adapt(pysqlite_state *state, PyObject *obj, if (!key) { return NULL; } - adapter = PyDict_GetItemWithError(state->psyco_adapters, key); + if (PyDict_GetItemRef(state->psyco_adapters, key, &adapter) < 0) { + Py_DECREF(key); + return NULL; + } Py_DECREF(key); if (adapter) { - Py_INCREF(adapter); adapted = PyObject_CallOneArg(adapter, obj); Py_DECREF(adapter); return adapted; } - if (PyErr_Occurred()) { - return NULL; - } /* try to have the protocol adapt this object */ - if (_PyObject_LookupAttr(proto, state->str___adapt__, &adapter) < 0) { + if (PyObject_GetOptionalAttr(proto, state->str___adapt__, &adapter) < 0) { return NULL; } if (adapter) { @@ -117,7 +116,7 @@ pysqlite_microprotocols_adapt(pysqlite_state *state, PyObject *obj, } /* and finally try to have the object adapt itself */ - if (_PyObject_LookupAttr(obj, state->str___conform__, &adapter) < 0) { + if (PyObject_GetOptionalAttr(obj, state->str___conform__, &adapter) < 0) { return NULL; } if (adapter) { |
