mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Use _PyObject_CallMethodIdObjArgs() in _io
Issue #28915: Replace _PyObject_CallMethodId() with _PyObject_CallMethodIdObjArgs() when the format string was only made of "O" formats, PyObject* arguments. _PyObject_CallMethodIdObjArgs() avoids the creation of a temporary tuple and doesn't have to parse a format string.
This commit is contained in:
parent
20401deae2
commit
61bdb0d319
5 changed files with 14 additions and 10 deletions
|
|
@ -85,7 +85,7 @@ char _PyIO_get_console_type(PyObject *path_or_fd) {
|
|||
Py_CLEAR(decoded);
|
||||
return '\0';
|
||||
}
|
||||
decoded_upper = PyObject_CallMethod(decoded, "upper", "");
|
||||
decoded_upper = PyObject_CallMethod(decoded, "upper", NULL);
|
||||
Py_CLEAR(decoded);
|
||||
if (!decoded_upper) {
|
||||
PyErr_Clear();
|
||||
|
|
@ -181,8 +181,8 @@ _io__WindowsConsoleIO_close_impl(winconsoleio *self)
|
|||
PyObject *exc, *val, *tb;
|
||||
int rc;
|
||||
_Py_IDENTIFIER(close);
|
||||
res = _PyObject_CallMethodId((PyObject*)&PyRawIOBase_Type,
|
||||
&PyId_close, "O", self);
|
||||
res = _PyObject_CallMethodIdObjArgs((PyObject*)&PyRawIOBase_Type,
|
||||
&PyId_close, self, NULL);
|
||||
if (!self->closehandle) {
|
||||
self->handle = INVALID_HANDLE_VALUE;
|
||||
return res;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue