summaryrefslogtreecommitdiffstats
path: root/Python/codecs.c
diff options
context:
space:
mode:
authorJeroen Demeyer <J.Demeyer@UGent.be>2019-07-04 10:31:34 (GMT)
committerInada Naoki <songofacandy@gmail.com>2019-07-04 10:31:34 (GMT)
commit196a530e00d88a138973bf9182e013937e293f97 (patch)
tree35443abb5aa148b459f68ae43a18cdbb0627ba76 /Python/codecs.c
parent9d40554e0da09a44a8547f3f3a2b9dedfeaf7928 (diff)
downloadcpython-196a530e00d88a138973bf9182e013937e293f97.zip
cpython-196a530e00d88a138973bf9182e013937e293f97.tar.gz
cpython-196a530e00d88a138973bf9182e013937e293f97.tar.bz2
bpo-37483: add _PyObject_CallOneArg() function (#14558)
Diffstat (limited to 'Python/codecs.c')
-rw-r--r--Python/codecs.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index d4b34f8..3865762 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -99,7 +99,7 @@ PyObject *normalizestring(const char *string)
PyObject *_PyCodec_Lookup(const char *encoding)
{
- PyObject *result, *args = NULL, *v;
+ PyObject *result, *v;
Py_ssize_t i, len;
if (encoding == NULL) {
@@ -132,13 +132,6 @@ PyObject *_PyCodec_Lookup(const char *encoding)
}
/* Next, scan the search functions in order of registration */
- args = PyTuple_New(1);
- if (args == NULL) {
- Py_DECREF(v);
- return NULL;
- }
- PyTuple_SET_ITEM(args,0,v);
-
len = PyList_Size(interp->codec_search_path);
if (len < 0)
goto onError;
@@ -155,7 +148,7 @@ PyObject *_PyCodec_Lookup(const char *encoding)
func = PyList_GetItem(interp->codec_search_path, i);
if (func == NULL)
goto onError;
- result = PyEval_CallObject(func, args);
+ result = _PyObject_CallOneArg(func, v);
if (result == NULL)
goto onError;
if (result == Py_None) {
@@ -182,11 +175,9 @@ PyObject *_PyCodec_Lookup(const char *encoding)
Py_DECREF(result);
goto onError;
}
- Py_DECREF(args);
return result;
onError:
- Py_XDECREF(args);
return NULL;
}
@@ -325,7 +316,7 @@ PyObject *codec_getstreamcodec(const char *encoding,
if (errors != NULL)
streamcodec = PyObject_CallFunction(codeccls, "Os", stream, errors);
else
- streamcodec = PyObject_CallFunctionObjArgs(codeccls, stream, NULL);
+ streamcodec = _PyObject_CallOneArg(codeccls, stream);
Py_DECREF(codecs);
return streamcodec;
}