Use _PyObject_CallMethodIdObjArgs()

Issue #28915: Replace _PyObject_CallMethodId() with
_PyObject_CallMethodIdObjArgs() when the format string only use the format 'O'
for objects, like "(O)".

_PyObject_CallMethodIdObjArgs() avoids the code to parse a format string and
avoids the creation of a temporary tuple.
This commit is contained in:
Victor Stinner 2016-12-09 00:36:19 +01:00
parent 4c38154a43
commit 7e42541d08
3 changed files with 5 additions and 4 deletions

View file

@ -2435,7 +2435,7 @@ _io_TextIOWrapper_tell_impl(textio *self)
}
finally:
res = _PyObject_CallMethodId(self->decoder, &PyId_setstate, "(O)", saved_state);
res = _PyObject_CallMethodIdObjArgs(self->decoder, &PyId_setstate, saved_state, NULL);
Py_DECREF(saved_state);
if (res == NULL)
return NULL;
@ -2449,7 +2449,7 @@ fail:
if (saved_state) {
PyObject *type, *value, *traceback;
PyErr_Fetch(&type, &value, &traceback);
res = _PyObject_CallMethodId(self->decoder, &PyId_setstate, "(O)", saved_state);
res = _PyObject_CallMethodIdObjArgs(self->decoder, &PyId_setstate, saved_state, NULL);
_PyErr_ChainExceptions(type, value, traceback);
Py_DECREF(saved_state);
Py_XDECREF(res);