mirror of https://github.com/python/cpython
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:
parent
4c38154a43
commit
7e42541d08
|
@ -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);
|
||||
|
|
|
@ -804,7 +804,8 @@ mappingproxy_get(mappingproxyobject *pp, PyObject *args)
|
|||
|
||||
if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &def))
|
||||
return NULL;
|
||||
return _PyObject_CallMethodId(pp->mapping, &PyId_get, "(OO)", key, def);
|
||||
return _PyObject_CallMethodIdObjArgs(pp->mapping, &PyId_get,
|
||||
key, def, NULL);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue