mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
gh-111789: Simplify the sqlite code (GH-111829)
Use new C API functions PyDict_GetItemRef() and PyMapping_GetOptionalItemString().
This commit is contained in:
parent
771bd3c94a
commit
afac3c9b7e
2 changed files with 6 additions and 17 deletions
|
@ -85,17 +85,16 @@ 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_GetOptionalAttr(proto, state->str___adapt__, &adapter) < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue