diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-11-10 22:49:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 20:49:24 +0000 |
commit | afac3c9b7eace4a3e503e93bb76eda32d8217ad7 (patch) | |
tree | 7b5a24775041e6667e89180e682d58dd26ff67cf /Modules/_sqlite/microprotocols.c | |
parent | 771bd3c94a366547e0c3451a72a430e1132c1ac1 (diff) | |
download | cpython-afac3c9b7eace4a3e503e93bb76eda32d8217ad7.tar.gz cpython-afac3c9b7eace4a3e503e93bb76eda32d8217ad7.zip |
gh-111789: Simplify the sqlite code (GH-111829)
Use new C API functions PyDict_GetItemRef() and
PyMapping_GetOptionalItemString().
Diffstat (limited to 'Modules/_sqlite/microprotocols.c')
-rw-r--r-- | Modules/_sqlite/microprotocols.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Modules/_sqlite/microprotocols.c b/Modules/_sqlite/microprotocols.c index 92f0148bd4c..f77458d94a8 100644 --- a/Modules/_sqlite/microprotocols.c +++ b/Modules/_sqlite/microprotocols.c @@ -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) { |