]> granicus.if.org Git - python/commitdiff
bpo-37547: add _PyObject_CallMethodOneArg (GH-14685)
authorJeroen Demeyer <J.Demeyer@UGent.be>
Thu, 11 Jul 2019 08:59:05 +0000 (10:59 +0200)
committerInada Naoki <songofacandy@gmail.com>
Thu, 11 Jul 2019 08:59:05 +0000 (17:59 +0900)
23 files changed:
Doc/c-api/object.rst
Include/cpython/abstract.h
Misc/NEWS.d/next/C API/2019-06-19-12-06-31.bpo-37337.gXIGyU.rst
Modules/_abc.c
Modules/_asynciomodule.c
Modules/_ctypes/callproc.c
Modules/_datetimemodule.c
Modules/_elementtree.c
Modules/_io/bufferedio.c
Modules/_io/fileio.c
Modules/_io/textio.c
Modules/_io/winconsoleio.c
Modules/_pickle.c
Modules/_sqlite/connection.c
Modules/arraymodule.c
Modules/cjkcodecs/multibytecodec.c
Objects/dictobject.c
Objects/typeobject.c
Python/_warnings.c
Python/ceval.c
Python/import.c
Python/marshal.c
Python/sysmodule.c

index 8ca034452954c3503bffc445f521c7ace758a7eb..2cf032821afbe5da9bf718fad3aa014cd66141a9 100644 (file)
@@ -375,6 +375,18 @@ Object Protocol
    .. versionadded:: 3.9
 
 
+.. c:function:: PyObject* _PyObject_CallMethodOneArg(PyObject *obj, PyObject *name, PyObject *arg)
+
+   Call a method of the Python object *obj* with a single positional argument
+   *arg*, where the name of the method is given as a Python string object in
+   *name*.
+
+   Return the result of the call on success, or raise an exception and return
+   *NULL* on failure.
+
+   .. versionadded:: 3.9
+
+
 .. c:function:: PyObject* _PyObject_Vectorcall(PyObject *callable, PyObject *const *args, size_t nargsf, PyObject *kwnames)
 
    Call a callable Python object *callable*, using
index e9a23195f414b3ebcb6e3987aa288b1db736a1d2..d57aa54bc4661205d3392ef15b3503633e9d8272 100644 (file)
@@ -163,6 +163,15 @@ _PyObject_CallMethodNoArgs(PyObject *self, PyObject *name)
            1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
 }
 
+static inline PyObject *
+_PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg)
+{
+    assert(arg != NULL);
+    PyObject *args[2] = {self, arg};
+    return _PyObject_VectorcallMethod(name, args,
+           2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+}
+
 /* Like PyObject_CallMethod(), but expect a _Py_Identifier*
    as the method name. */
 PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj,
@@ -198,6 +207,15 @@ _PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name)
            1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
 }
 
+static inline PyObject *
+_PyObject_CallMethodIdOneArg(PyObject *self, _Py_Identifier *name, PyObject *arg)
+{
+    assert(arg != NULL);
+    PyObject *args[2] = {self, arg};
+    return _PyObject_VectorcallMethodId(name, args,
+           2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+}
+
 PyAPI_FUNC(int) _PyObject_HasLen(PyObject *o);
 
 /* Guess the size of object 'o' using len(o) or o.__length_hint__().
index df0e807e11666d361481e52632e394de2f036a81..63b355ecdb3362fc751998f01576d4dd8df30b98 100644 (file)
@@ -1,2 +1,2 @@
-Add fast functions for calling methods: :c:func:`_PyObject_VectorcallMethod`
-and :c:func:`_PyObject_CallMethodNoArgs`
+Add fast functions for calling methods: :c:func:`_PyObject_VectorcallMethod`,
+:c:func:`_PyObject_CallMethodNoArgs` and :c:func:`_PyObject_CallMethodOneArg`.
index 219ea0dd628fa1924caf99130d579e14d6943be6..7b5d4180bf87399ca33a4ff4687461168c87f9a6 100644 (file)
@@ -480,7 +480,6 @@ _abc__abc_instancecheck_impl(PyObject *module, PyObject *self,
 /*[clinic end generated code: output=b8b5148f63b6b56f input=a4f4525679261084]*/
 {
     PyObject *subtype, *result = NULL, *subclass = NULL;
-    PyObject *margs[2];
     _abc_data *impl = _get_impl(self);
     if (impl == NULL) {
         return NULL;
@@ -515,16 +514,12 @@ _abc__abc_instancecheck_impl(PyObject *module, PyObject *self,
             }
         }
         /* Fall back to the subclass check. */
-        margs[0] = self;
-        margs[1] = subclass;
-        result = _PyObject_VectorcallMethodId(&PyId___subclasscheck__, margs,
-            2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+        result = _PyObject_CallMethodIdOneArg(self, &PyId___subclasscheck__,
+                                              subclass);
         goto end;
     }
-    margs[0] = self;
-    margs[1] = subclass;
-    result = _PyObject_VectorcallMethodId(&PyId___subclasscheck__, margs,
-        2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+    result = _PyObject_CallMethodIdOneArg(self, &PyId___subclasscheck__,
+                                          subclass);
     if (result == NULL) {
         goto end;
     }
@@ -536,10 +531,8 @@ _abc__abc_instancecheck_impl(PyObject *module, PyObject *self,
         break;
     case 0:
         Py_DECREF(result);
-        margs[0] = self;
-        margs[1] = subtype;
-        result = _PyObject_VectorcallMethodId(&PyId___subclasscheck__, margs,
-            2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+        result = _PyObject_CallMethodIdOneArg(self, &PyId___subclasscheck__,
+                                              subtype);
         break;
     case 1:  // Nothing to do.
         break;
@@ -620,8 +613,8 @@ _abc__abc_subclasscheck_impl(PyObject *module, PyObject *self,
     }
 
     /* 3. Check the subclass hook. */
-    ok = _PyObject_CallMethodIdObjArgs((PyObject *)self, &PyId___subclasshook__,
-                                       subclass, NULL);
+    ok = _PyObject_CallMethodIdOneArg((PyObject *)self, &PyId___subclasshook__,
+                                      subclass);
     if (ok == NULL) {
         goto end;
     }
index 6c469d2a2ec589162ad598edb6ea9728d73a9879..e9e6c5682d62e9116ad72580444b243677246cea 100644 (file)
@@ -1842,8 +1842,8 @@ register_task(PyObject *task)
 {
     _Py_IDENTIFIER(add);
 
-    PyObject *res = _PyObject_CallMethodIdObjArgs(
-        all_tasks, &PyId_add, task, NULL);
+    PyObject *res = _PyObject_CallMethodIdOneArg(all_tasks,
+                                                 &PyId_add, task);
     if (res == NULL) {
         return -1;
     }
@@ -1857,8 +1857,8 @@ unregister_task(PyObject *task)
 {
     _Py_IDENTIFIER(discard);
 
-    PyObject *res = _PyObject_CallMethodIdObjArgs(
-        all_tasks, &PyId_discard, task, NULL);
+    PyObject *res = _PyObject_CallMethodIdOneArg(all_tasks,
+                                                 &PyId_discard, task);
     if (res == NULL) {
         return -1;
     }
@@ -2611,13 +2611,11 @@ task_step_impl(TaskObj *task, PyObject *exc)
             result = _PyGen_Send((PyGenObject*)coro, Py_None);
         }
         else {
-            result = _PyObject_CallMethodIdObjArgs(coro, &PyId_send,
-                                                   Py_None, NULL);
+            result = _PyObject_CallMethodIdOneArg(coro, &PyId_send, Py_None);
         }
     }
     else {
-        result = _PyObject_CallMethodIdObjArgs(coro, &PyId_throw,
-                                               exc, NULL);
+        result = _PyObject_CallMethodIdOneArg(coro, &PyId_throw, exc);
         if (clear_exc) {
             /* We created 'exc' during this call */
             Py_DECREF(exc);
index 973a654bf355240e2dfcf13ffe4a6eb4c98439dd..bd67c6eeaeed30b7361bfca174f6b79eb0ba7cec 100644 (file)
@@ -1699,7 +1699,7 @@ unpickle(PyObject *self, PyObject *args)
 
     if (!PyArg_ParseTuple(args, "OO!", &typ, &PyTuple_Type, &state))
         return NULL;
-    obj = _PyObject_CallMethodIdObjArgs(typ, &PyId___new__, typ, NULL);
+    obj = _PyObject_CallMethodIdOneArg(typ, &PyId___new__, typ);
     if (obj == NULL)
         return NULL;
 
index 0546368d1df7d5346244eaa8f64ae51a82031d7d..19d3d7e848f5cafa73076f48c6cd32c7c44ed78b 100644 (file)
@@ -1237,8 +1237,7 @@ call_tzname(PyObject *tzinfo, PyObject *tzinfoarg)
     if (tzinfo == Py_None)
         Py_RETURN_NONE;
 
-    result = _PyObject_CallMethodIdObjArgs(tzinfo, &PyId_tzname,
-                                           tzinfoarg, NULL);
+    result = _PyObject_CallMethodIdOneArg(tzinfo, &PyId_tzname, tzinfoarg);
 
     if (result == NULL || result == Py_None)
         return result;
@@ -1693,8 +1692,7 @@ build_struct_time(int y, int m, int d, int hh, int mm, int ss, int dstflag)
         return NULL;
     }
 
-    result = _PyObject_CallMethodIdObjArgs(time, &PyId_struct_time,
-                                           args, NULL);
+    result = _PyObject_CallMethodIdOneArg(time, &PyId_struct_time, args);
     Py_DECREF(time);
     Py_DECREF(args);
     return result;
@@ -2894,8 +2892,7 @@ date_today(PyObject *cls, PyObject *dummy)
      * time.time() delivers; if someone were gonzo about optimization,
      * date.today() could get away with plain C time().
      */
-    result = _PyObject_CallMethodIdObjArgs(cls, &PyId_fromtimestamp,
-                                           time, NULL);
+    result = _PyObject_CallMethodIdOneArg(cls, &PyId_fromtimestamp, time);
     Py_DECREF(time);
     return result;
 }
@@ -3209,8 +3206,8 @@ date_format(PyDateTime_Date *self, PyObject *args)
     if (PyUnicode_GetLength(format) == 0)
         return PyObject_Str((PyObject *)self);
 
-    return _PyObject_CallMethodIdObjArgs((PyObject *)self, &PyId_strftime,
-                                         format, NULL);
+    return _PyObject_CallMethodIdOneArg((PyObject *)self, &PyId_strftime,
+                                        format);
 }
 
 /* ISO methods. */
@@ -5960,7 +5957,7 @@ datetime_astimezone(PyDateTime_DateTime *self, PyObject *args, PyObject *kw)
 
     temp = (PyObject *)result;
     result = (PyDateTime_DateTime *)
-        _PyObject_CallMethodIdObjArgs(tzinfo, &PyId_fromutc, temp, NULL);
+        _PyObject_CallMethodIdOneArg(tzinfo, &PyId_fromutc, temp);
     Py_DECREF(temp);
 
     return result;
index b93ec3d12786066c33f9ba378ba92208851e0ce2..b9b50165bfdad3d7e3b5185a08cd27cc91488d76 100644 (file)
@@ -2679,7 +2679,7 @@ treebuilder_add_subelement(PyObject *element, PyObject *child)
     }
     else {
         PyObject *res;
-        res = _PyObject_CallMethodIdObjArgs(element, &PyId_append, child, NULL);
+        res = _PyObject_CallMethodIdOneArg(element, &PyId_append, child);
         if (res == NULL)
             return -1;
         Py_DECREF(res);
index 9e7e5f3d0935dc77ef0a499a426f96001f70d227..86dd277f94c1bf0493439425140eadd077a056b0 100644 (file)
@@ -439,8 +439,8 @@ buffered_dealloc_warn(buffered *self, PyObject *source)
 {
     if (self->ok && self->raw) {
         PyObject *r;
-        r = _PyObject_CallMethodIdObjArgs(self->raw, &PyId__dealloc_warn,
-                                          source, NULL);
+        r = _PyObject_CallMethodIdOneArg(self->raw, &PyId__dealloc_warn,
+                                         source);
         if (r)
             Py_DECREF(r);
         else
@@ -1323,7 +1323,7 @@ _io__Buffered_truncate_impl(buffered *self, PyObject *pos)
             goto end;
         Py_CLEAR(res);
     }
-    res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_truncate, pos, NULL);
+    res = _PyObject_CallMethodOneArg(self->raw, _PyIO_str_truncate, pos);
     if (res == NULL)
         goto end;
     /* Reset cached position */
@@ -1467,7 +1467,7 @@ _bufferedreader_raw_read(buffered *self, char *start, Py_ssize_t len)
        raised (see issue #10956).
     */
     do {
-        res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_readinto, memobj, NULL);
+        res = _PyObject_CallMethodOneArg(self->raw, _PyIO_str_readinto, memobj);
     } while (res == NULL && _PyIO_trap_eintr());
     Py_DECREF(memobj);
     if (res == NULL)
@@ -1815,7 +1815,7 @@ _bufferedwriter_raw_write(buffered *self, char *start, Py_ssize_t len)
     */
     do {
         errno = 0;
-        res = PyObject_CallMethodObjArgs(self->raw, _PyIO_str_write, memobj, NULL);
+        res = _PyObject_CallMethodOneArg(self->raw, _PyIO_str_write, memobj);
         errnum = errno;
     } while (res == NULL && _PyIO_trap_eintr());
     Py_DECREF(memobj);
index 7f784a34c30d335dcfb4810de6e56d093e8e1a95..e4cbbfa9bb8cd43a53bb3755db96ee2aef41ccf3 100644 (file)
@@ -145,8 +145,8 @@ _io_FileIO_close_impl(fileio *self)
     PyObject *exc, *val, *tb;
     int rc;
     _Py_IDENTIFIER(close);
-    res = _PyObject_CallMethodIdObjArgs((PyObject*)&PyRawIOBase_Type,
-                                        &PyId_close, self, NULL);
+    res = _PyObject_CallMethodIdOneArg((PyObject*)&PyRawIOBase_Type,
+                                       &PyId_close, (PyObject *)self);
     if (!self->closefd) {
         self->fd = -1;
         return res;
index ed1dc005c69a174dcd792f6582edf83d6088839e..05911d9222ff6e60955d9b92d66a0a856956c979 100644 (file)
@@ -977,8 +977,8 @@ _textiowrapper_fix_encoder_state(textio *self)
 
     if (cmp == 0) {
         self->encoding_start_of_stream = 0;
-        PyObject *res = PyObject_CallMethodObjArgs(
-            self->encoder, _PyIO_str_setstate, _PyLong_Zero, NULL);
+        PyObject *res = _PyObject_CallMethodOneArg(
+            self->encoder, _PyIO_str_setstate, _PyLong_Zero);
         if (res == NULL) {
             return -1;
         }
@@ -1155,8 +1155,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_CallMethodIdObjArgs(
-            locale_module, &PyId_getpreferredencoding, Py_False, NULL);
+        self->encoding = _PyObject_CallMethodIdOneArg(
+            locale_module, &PyId_getpreferredencoding, Py_False);
         Py_DECREF(locale_module);
         if (self->encoding == NULL) {
           catch_ImportError:
@@ -1597,8 +1597,7 @@ _textiowrapper_writeflush(textio *self)
 
     PyObject *ret;
     do {
-        ret = PyObject_CallMethodObjArgs(self->buffer,
-                                         _PyIO_str_write, b, NULL);
+        ret = _PyObject_CallMethodOneArg(self->buffer, _PyIO_str_write, b);
     } while (ret == NULL && _PyIO_trap_eintr());
     Py_DECREF(b);
     if (ret == NULL)
@@ -1668,8 +1667,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text)
         self->encoding_start_of_stream = 0;
     }
     else
-        b = PyObject_CallMethodObjArgs(self->encoder,
-                                       _PyIO_str_encode, text, NULL);
+        b = _PyObject_CallMethodOneArg(self->encoder, _PyIO_str_encode, text);
 
     Py_DECREF(text);
     if (b == NULL)
@@ -1851,9 +1849,9 @@ textiowrapper_read_chunk(textio *self, Py_ssize_t size_hint)
     if (chunk_size == NULL)
         goto fail;
 
-    input_chunk = PyObject_CallMethodObjArgs(self->buffer,
+    input_chunk = _PyObject_CallMethodOneArg(self->buffer,
         (self->has_read1 ? _PyIO_str_read1: _PyIO_str_read),
-        chunk_size, NULL);
+        chunk_size);
     Py_DECREF(chunk_size);
     if (input_chunk == NULL)
         goto fail;
@@ -2414,8 +2412,8 @@ _textiowrapper_encoder_reset(textio *self, int start_of_stream)
         self->encoding_start_of_stream = 1;
     }
     else {
-        res = PyObject_CallMethodObjArgs(self->encoder, _PyIO_str_setstate,
-                                         _PyLong_Zero, NULL);
+        res = _PyObject_CallMethodOneArg(self->encoder, _PyIO_str_setstate,
+                                        _PyLong_Zero);
         self->encoding_start_of_stream = 0;
     }
     if (res == NULL)
@@ -2554,8 +2552,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence)
     posobj = PyLong_FromOff_t(cookie.start_pos);
     if (posobj == NULL)
         goto fail;
-    res = PyObject_CallMethodObjArgs(self->buffer,
-                                     _PyIO_str_seek, posobj, NULL);
+    res = _PyObject_CallMethodOneArg(self->buffer, _PyIO_str_seek, posobj);
     Py_DECREF(posobj);
     if (res == NULL)
         goto fail;
@@ -2837,7 +2834,7 @@ _io_TextIOWrapper_tell_impl(textio *self)
     }
 
 finally:
-    res = _PyObject_CallMethodIdObjArgs(self->decoder, &PyId_setstate, saved_state, NULL);
+    res = _PyObject_CallMethodIdOneArg(self->decoder, &PyId_setstate, saved_state);
     Py_DECREF(saved_state);
     if (res == NULL)
         return NULL;
@@ -2851,7 +2848,7 @@ fail:
     if (saved_state) {
         PyObject *type, *value, *traceback;
         PyErr_Fetch(&type, &value, &traceback);
-        res = _PyObject_CallMethodIdObjArgs(self->decoder, &PyId_setstate, saved_state, NULL);
+        res = _PyObject_CallMethodIdOneArg(self->decoder, &PyId_setstate, saved_state);
         _PyErr_ChainExceptions(type, value, traceback);
         Py_DECREF(saved_state);
         Py_XDECREF(res);
@@ -2878,7 +2875,7 @@ _io_TextIOWrapper_truncate_impl(textio *self, PyObject *pos)
         return NULL;
     Py_DECREF(res);
 
-    return PyObject_CallMethodObjArgs(self->buffer, _PyIO_str_truncate, pos, NULL);
+    return _PyObject_CallMethodOneArg(self->buffer, _PyIO_str_truncate, pos);
 }
 
 static PyObject *
@@ -3055,9 +3052,9 @@ _io_TextIOWrapper_close_impl(textio *self)
     else {
         PyObject *exc = NULL, *val, *tb;
         if (self->finalizing) {
-            res = _PyObject_CallMethodIdObjArgs(self->buffer,
-                                                &PyId__dealloc_warn,
-                                                self, NULL);
+            res = _PyObject_CallMethodIdOneArg(self->buffer,
+                                              &PyId__dealloc_warn,
+                                              (PyObject *)self);
             if (res)
                 Py_DECREF(res);
             else
index ea5d24f950a1e24f79a5b21c595ce1bba3f3e0d8..f27a6dc93a2b1bcf3aa77c8388bf6de2f18ea603 100644 (file)
@@ -204,8 +204,8 @@ _io__WindowsConsoleIO_close_impl(winconsoleio *self)
     PyObject *exc, *val, *tb;
     int rc;
     _Py_IDENTIFIER(close);
-    res = _PyObject_CallMethodIdObjArgs((PyObject*)&PyRawIOBase_Type,
-                                        &PyId_close, self, NULL);
+    res = _PyObject_CallMethodIdOneArg((PyObject*)&PyRawIOBase_Type,
+                                       &PyId_close, self);
     if (!self->closehandle) {
         self->handle = INVALID_HANDLE_VALUE;
         return res;
index 0b0928f5cd2fa8e51307cbb48581cc7e3993e37f..735c13d03d8fe46f2ecc685d2a90756afe6c2c36 100644 (file)
@@ -5773,7 +5773,7 @@ instantiate(PyObject *cls, PyObject *args)
             return NULL;
         }
         if (func == NULL) {
-            return _PyObject_CallMethodIdObjArgs(cls, &PyId___new__, cls, NULL);
+            return _PyObject_CallMethodIdOneArg(cls, &PyId___new__, cls);
         }
         Py_DECREF(func);
     }
index 30a9b889a9df199c96c871d26b393c0ef241a7ce..47b8b62cea26cf9dbe5d7c3397d2cd8181f470f4 100644 (file)
@@ -1185,9 +1185,9 @@ pysqlite_connection_set_isolation_level(pysqlite_Connection* self, PyObject* iso
             return -1;
         }
 
-        uppercase_level = _PyObject_CallMethodIdObjArgs(
+        uppercase_level = _PyObject_CallMethodIdOneArg(
                         (PyObject *)&PyUnicode_Type, &PyId_upper,
-                        isolation_level, NULL);
+                        isolation_level);
         if (!uppercase_level) {
             return -1;
         }
@@ -1648,8 +1648,8 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
         goto finally;
     }
 
-    uppercase_name = _PyObject_CallMethodIdObjArgs((PyObject *)&PyUnicode_Type,
-                                                   &PyId_upper, name, NULL);
+    uppercase_name = _PyObject_CallMethodIdOneArg((PyObject *)&PyUnicode_Type,
+                                                  &PyId_upper, name);
     if (!uppercase_name) {
         goto finally;
     }
index 26c90a8a5983d4a7b6fc6cd1d2cf91c0aeae741b..48986c4190297560421b06183031ad1fede25c69 100644 (file)
@@ -1507,7 +1507,7 @@ array_array_tofile(arrayobject *self, PyObject *f)
         bytes = PyBytes_FromStringAndSize(ptr, size);
         if (bytes == NULL)
             return NULL;
-        res = _PyObject_CallMethodIdObjArgs(f, &PyId_write, bytes, NULL);
+        res = _PyObject_CallMethodIdOneArg(f, &PyId_write, bytes);
         Py_DECREF(bytes);
         if (res == NULL)
             return NULL;
index 052ed8878c1c5a8d1feca8933879099b6b8af56c..4de678757b38adca09dee8052f7e571a895f585b 100644 (file)
@@ -1776,7 +1776,7 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self,
     if (str == NULL)
         return -1;
 
-    wr = _PyObject_CallMethodIdObjArgs(self->stream, &PyId_write, str, NULL);
+    wr = _PyObject_CallMethodIdOneArg(self->stream, &PyId_write, str);
     Py_DECREF(str);
     if (wr == NULL)
         return -1;
@@ -1870,7 +1870,7 @@ _multibytecodec_MultibyteStreamWriter_reset_impl(MultibyteStreamWriterObject *se
     if (PyBytes_Size(pwrt) > 0) {
         PyObject *wr;
 
-        wr = _PyObject_CallMethodIdObjArgs(self->stream, &PyId_write, pwrt);
+        wr = _PyObject_CallMethodIdOneArg(self->stream, &PyId_write, pwrt);
         if (wr == NULL) {
             Py_DECREF(pwrt);
             return NULL;
index 422f4b0230ba98ebbb347b38ba0416f9cdaaf9c1..b6205d93ca1408f134902aa1943040f1445d8fb9 100644 (file)
@@ -4159,7 +4159,7 @@ dictviews_sub(PyObject* self, PyObject *other)
     if (result == NULL)
         return NULL;
 
-    tmp = _PyObject_CallMethodIdObjArgs(result, &PyId_difference_update, other, NULL);
+    tmp = _PyObject_CallMethodIdOneArg(result, &PyId_difference_update, other);
     if (tmp == NULL) {
         Py_DECREF(result);
         return NULL;
@@ -4179,7 +4179,7 @@ _PyDictView_Intersect(PyObject* self, PyObject *other)
     if (result == NULL)
         return NULL;
 
-    tmp = _PyObject_CallMethodIdObjArgs(result, &PyId_intersection_update, other, NULL);
+    tmp = _PyObject_CallMethodIdOneArg(result, &PyId_intersection_update, other);
     if (tmp == NULL) {
         Py_DECREF(result);
         return NULL;
@@ -4199,7 +4199,7 @@ dictviews_or(PyObject* self, PyObject *other)
     if (result == NULL)
         return NULL;
 
-    tmp = _PyObject_CallMethodIdObjArgs(result, &PyId_update, other, NULL);
+    tmp = _PyObject_CallMethodIdOneArg(result, &PyId_update, other);
     if (tmp == NULL) {
         Py_DECREF(result);
         return NULL;
@@ -4219,7 +4219,7 @@ dictviews_xor(PyObject* self, PyObject *other)
     if (result == NULL)
         return NULL;
 
-    tmp = _PyObject_CallMethodIdObjArgs(result, &PyId_symmetric_difference_update, other, NULL);
+    tmp = _PyObject_CallMethodIdOneArg(result, &PyId_symmetric_difference_update, other);
     if (tmp == NULL) {
         Py_DECREF(result);
         return NULL;
index 96021eeccc57e35e9ef3c6e1fb2d478b31aedb60..8acf678fc9a4597c6d14d55c36a1229d874c0e68 100644 (file)
@@ -4145,8 +4145,8 @@ _PyType_GetSlotNames(PyTypeObject *cls)
     /* Use _slotnames function from the copyreg module to find the slots
        by this class and its bases. This function will cache the result
        in __slotnames__. */
-    slotnames = _PyObject_CallMethodIdObjArgs(copyreg, &PyId__slotnames,
-                                              cls, NULL);
+    slotnames = _PyObject_CallMethodIdOneArg(copyreg, &PyId__slotnames,
+                                             (PyObject *)cls);
     Py_DECREF(copyreg);
     if (slotnames == NULL)
         return NULL;
index b1762e6bedaf1f7d4e35fc23c3fce7e9eb8b5121..ecee399db6e8de70014f58a0dd2d19037f07cec2 100644 (file)
@@ -164,7 +164,7 @@ check_matched(PyObject *obj, PyObject *arg)
     }
 
     /* Otherwise assume a regex filter and call its match() method */
-    result = _PyObject_CallMethodIdObjArgs(obj, &PyId_match, arg, NULL);
+    result = _PyObject_CallMethodIdOneArg(obj, &PyId_match, arg);
     if (result == NULL)
         return -1;
 
index fdd299561c6156d1633a7d142f15de3af8406b95..7c7359166dad91f20a82c79a209c2266a1a705ac 100644 (file)
@@ -2052,7 +2052,7 @@ main_loop:
                 if (v == Py_None)
                     retval = Py_TYPE(receiver)->tp_iternext(receiver);
                 else
-                    retval = _PyObject_CallMethodIdObjArgs(receiver, &PyId_send, v, NULL);
+                    retval = _PyObject_CallMethodIdOneArg(receiver, &PyId_send, v);
             }
             Py_DECREF(v);
             if (retval == NULL) {
index df258751c82ee57d715dce47b1847c9819ffd00d..15f1d94176008eec8b660311d027bb593c30f4cf 100644 (file)
@@ -962,9 +962,8 @@ PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co,
         external= PyObject_GetAttrString(interp->importlib,
                                          "_bootstrap_external");
         if (external != NULL) {
-            pathobj = _PyObject_CallMethodIdObjArgs(external,
-                                                    &PyId__get_sourcefile, cpathobj,
-                                                    NULL);
+            pathobj = _PyObject_CallMethodIdOneArg(
+                external, &PyId__get_sourcefile, cpathobj);
             Py_DECREF(external);
         }
         if (pathobj == NULL)
@@ -1827,9 +1826,8 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
          */
         spec = _PyObject_GetAttrId(mod, &PyId___spec__);
         if (_PyModuleSpec_IsInitializing(spec)) {
-            PyObject *value = _PyObject_CallMethodIdObjArgs(interp->importlib,
-                                            &PyId__lock_unlock_module, abs_name,
-                                            NULL);
+            PyObject *value = _PyObject_CallMethodIdOneArg(
+                interp->importlib, &PyId__lock_unlock_module, abs_name);
             if (value == NULL) {
                 Py_DECREF(spec);
                 goto error;
@@ -1968,7 +1966,7 @@ PyImport_ReloadModule(PyObject *m)
         }
     }
 
-    reloaded_module = _PyObject_CallMethodIdObjArgs(imp, &PyId_reload, m, NULL);
+    reloaded_module = _PyObject_CallMethodIdOneArg(imp, &PyId_reload, m);
     Py_DECREF(imp);
     return reloaded_module;
 }
index b2daff2c8a3bef06a01e9a9ba07bc1fef2459c33..cb11c8c74ef3a6409dbcae1dfcbb458952c05354 100644 (file)
@@ -1653,7 +1653,7 @@ marshal_dump_impl(PyObject *module, PyObject *value, PyObject *file,
     s = PyMarshal_WriteObjectToString(value, version);
     if (s == NULL)
         return NULL;
-    res = _PyObject_CallMethodIdObjArgs(file, &PyId_write, s, NULL);
+    res = _PyObject_CallMethodIdOneArg(file, &PyId_write, s);
     Py_DECREF(s);
     return res;
 }
index dc198a5d1e05f12c632bfb0dfe2f723e4dd3c04c..103a11152412117802b245dbe38c02b2b07cb44c 100644 (file)
@@ -581,7 +581,7 @@ sys_displayhook_unencodable(PyThreadState *tstate, PyObject *outf, PyObject *o)
 
     buffer = _PyObject_GetAttrId(outf, &PyId_buffer);
     if (buffer) {
-        result = _PyObject_CallMethodIdObjArgs(buffer, &PyId_write, encoded, NULL);
+        result = _PyObject_CallMethodIdOneArg(buffer, &PyId_write, encoded);
         Py_DECREF(buffer);
         Py_DECREF(encoded);
         if (result == NULL)
@@ -3114,9 +3114,7 @@ sys_pyfile_write_unicode(PyObject *unicode, PyObject *file)
     if (file == NULL)
         return -1;
     assert(unicode != NULL);
-    PyObject *margs[2] = {file, unicode};
-    PyObject *result = _PyObject_VectorcallMethodId(&PyId_write, margs,
-        2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
+    PyObject *result = _PyObject_CallMethodIdOneArg(file, &PyId_write, unicode);
     if (result == NULL) {
         return -1;
     }