From ff4988fe1c104125462faa6d68d1f2c957b00727 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 9 Dec 2016 00:36:19 +0100 Subject: 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. --- Modules/_io/textio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Modules/_io/textio.c') diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 1c7200b0ae..d28f613950 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -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); -- cgit v1.2.1 From 09b2d50c0d8d51d884e87076f54671845be322d5 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 9 Dec 2016 15:39:28 +0100 Subject: 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. --- Modules/_io/textio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Modules/_io/textio.c') diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index d28f613950..0a6dfe1b33 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -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 -- cgit v1.2.1