bpo-37483: add _PyObject_CallOneArg() function (#14558)

This commit is contained in:
Jeroen Demeyer 2019-07-04 12:31:34 +02:00 committed by Inada Naoki
parent 9d40554e0d
commit 196a530e00
44 changed files with 128 additions and 146 deletions

View file

@ -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) {

View file

@ -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;
}

View file

@ -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 {

View file

@ -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) {