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

@ -130,7 +130,7 @@ sys_displayhook_unencodable(PyObject *outf, PyObject *o)
buffer = _PyObject_GetAttrId(outf, &PyId_buffer);
if (buffer) {
result = _PyObject_CallMethodId(buffer, &PyId_write, "(O)", encoded);
result = _PyObject_CallMethodIdObjArgs(buffer, &PyId_write, encoded, NULL);
Py_DECREF(buffer);
Py_DECREF(encoded);
if (result == NULL)