mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +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
|
|
@ -899,8 +899,8 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
|
|||
PyObject *locale_module = _PyIO_get_locale_module(state);
|
||||
if (locale_module == NULL)
|
||||
goto catch_ImportError;
|
||||
self->encoding = _PyObject_CallMethodId(
|
||||
locale_module, &PyId_getpreferredencoding, "O", Py_False);
|
||||
self->encoding = _PyObject_CallMethodIdObjArgs(
|
||||
locale_module, &PyId_getpreferredencoding, Py_False, NULL);
|
||||
Py_DECREF(locale_module);
|
||||
if (self->encoding == NULL) {
|
||||
catch_ImportError:
|
||||
|
|
@ -2644,7 +2644,9 @@ _io_TextIOWrapper_close_impl(textio *self)
|
|||
else {
|
||||
PyObject *exc = NULL, *val, *tb;
|
||||
if (self->finalizing) {
|
||||
res = _PyObject_CallMethodId(self->buffer, &PyId__dealloc_warn, "O", self);
|
||||
res = _PyObject_CallMethodIdObjArgs(self->buffer,
|
||||
&PyId__dealloc_warn,
|
||||
self, NULL);
|
||||
if (res)
|
||||
Py_DECREF(res);
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue