diff options
author | Jeroen Demeyer <J.Demeyer@UGent.be> | 2019-07-04 10:31:34 (GMT) |
---|---|---|
committer | Inada Naoki <songofacandy@gmail.com> | 2019-07-04 10:31:34 (GMT) |
commit | 196a530e00d88a138973bf9182e013937e293f97 (patch) | |
tree | 35443abb5aa148b459f68ae43a18cdbb0627ba76 /Modules/_sqlite | |
parent | 9d40554e0da09a44a8547f3f3a2b9dedfeaf7928 (diff) | |
download | cpython-196a530e00d88a138973bf9182e013937e293f97.zip cpython-196a530e00d88a138973bf9182e013937e293f97.tar.gz cpython-196a530e00d88a138973bf9182e013937e293f97.tar.bz2 |
bpo-37483: add _PyObject_CallOneArg() function (#14558)
Diffstat (limited to 'Modules/_sqlite')
-rw-r--r-- | Modules/_sqlite/cache.c | 6 | ||||
-rw-r--r-- | Modules/_sqlite/connection.c | 13 | ||||
-rw-r--r-- | Modules/_sqlite/cursor.c | 2 | ||||
-rw-r--r-- | Modules/_sqlite/microprotocols.c | 6 |
4 files changed, 11 insertions, 16 deletions
diff --git a/Modules/_sqlite/cache.c b/Modules/_sqlite/cache.c index 4d41804..7552d1b 100644 --- a/Modules/_sqlite/cache.c +++ b/Modules/_sqlite/cache.c @@ -112,9 +112,8 @@ void pysqlite_cache_dealloc(pysqlite_Cache* self) Py_TYPE(self)->tp_free((PyObject*)self); } -PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args) +PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* key) { - PyObject* key = args; pysqlite_Node* node; pysqlite_Node* ptr; PyObject* data; @@ -184,6 +183,9 @@ PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args) } } + /* We cannot replace this by _PyObject_CallOneArg() since + * PyObject_CallFunction() has a special case when using a + * single tuple as argument. */ data = PyObject_CallFunction(self->factory, "O", key); if (!data) { diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 5ceeaf9..08604b9 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -310,7 +310,7 @@ PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, factory = (PyObject*)&pysqlite_CursorType; } - cursor = PyObject_CallFunctionObjArgs(factory, (PyObject *)self, NULL); + cursor = _PyObject_CallOneArg(factory, (PyObject *)self); if (cursor == NULL) return NULL; if (!PyObject_TypeCheck(cursor, &pysqlite_CursorType)) { @@ -970,7 +970,7 @@ static void _trace_callback(void* user_arg, const char* statement_string) py_statement = PyUnicode_DecodeUTF8(statement_string, strlen(statement_string), "replace"); if (py_statement) { - ret = PyObject_CallFunctionObjArgs((PyObject*)user_arg, py_statement, NULL); + ret = _PyObject_CallOneArg((PyObject*)user_arg, py_statement); Py_DECREF(py_statement); } @@ -1465,16 +1465,9 @@ pysqlite_connection_iterdump(pysqlite_Connection* self, PyObject* args) goto finally; } - args = PyTuple_New(1); - if (!args) { - goto finally; - } - Py_INCREF(self); - PyTuple_SetItem(args, 0, (PyObject*)self); - retval = PyObject_CallObject(pyfn_iterdump, args); + retval = _PyObject_CallOneArg(pyfn_iterdump, (PyObject *)self); finally: - Py_XDECREF(args); Py_XDECREF(module); return retval; } diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c index 38d94b2..e6fcac8 100644 --- a/Modules/_sqlite/cursor.c +++ b/Modules/_sqlite/cursor.c @@ -266,7 +266,7 @@ _pysqlite_fetch_one_row(pysqlite_Cursor* self) item = PyBytes_FromStringAndSize(val_str, nbytes); if (!item) goto error; - converted = PyObject_CallFunction(converter, "O", item); + converted = _PyObject_CallOneArg(converter, item); Py_DECREF(item); } } else { diff --git a/Modules/_sqlite/microprotocols.c b/Modules/_sqlite/microprotocols.c index c23b09f..59a5e22 100644 --- a/Modules/_sqlite/microprotocols.c +++ b/Modules/_sqlite/microprotocols.c @@ -92,7 +92,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) Py_DECREF(key); if (adapter) { Py_INCREF(adapter); - adapted = PyObject_CallFunctionObjArgs(adapter, obj, NULL); + adapted = _PyObject_CallOneArg(adapter, obj); Py_DECREF(adapter); return adapted; } @@ -105,7 +105,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) return NULL; } if (adapter) { - adapted = PyObject_CallFunctionObjArgs(adapter, obj, NULL); + adapted = _PyObject_CallOneArg(adapter, obj); Py_DECREF(adapter); if (adapted == Py_None) { @@ -124,7 +124,7 @@ pysqlite_microprotocols_adapt(PyObject *obj, PyObject *proto, PyObject *alt) return NULL; } if (adapter) { - adapted = PyObject_CallFunctionObjArgs(adapter, proto, NULL); + adapted = _PyObject_CallOneArg(adapter, proto); Py_DECREF(adapter); if (adapted == Py_None) { |