]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106084: Remove old PyObject call aliases (#106085)
authorVictor Stinner <vstinner@python.org>
Mon, 26 Jun 2023 06:08:12 +0000 (08:08 +0200)
committerGitHub <noreply@github.com>
Mon, 26 Jun 2023 06:08:12 +0000 (08:08 +0200)
Remove old aliases which were kept backwards compatibility with
Python 3.8:

* _PyObject_CallMethodNoArgs()
* _PyObject_CallMethodOneArg()
* _PyObject_CallOneArg()
* _PyObject_FastCallDict()
* _PyObject_Vectorcall()
* _PyObject_VectorcallMethod()
* _PyVectorcall_Function()

Update code which used these aliases to use new names.

12 files changed:
Doc/whatsnew/3.13.rst
Include/cpython/abstract.h
Misc/NEWS.d/next/C API/2023-06-25-18-01-27.gh-issue-106084.PEzqU3.rst [new file with mode: 0644]
Modules/_functoolsmodule.c
Modules/cjkcodecs/multibytecodec.c
Objects/call.c
Objects/descrobject.c
Python/errors.c
Python/import.c
Python/marshal.c
Python/pythonrun.c
Python/sysmodule.c

index d1f13a50335b5bf644b0c38ba317b3d463fcc86d..ee8c198734076d2431aaabcc3964cf532fdcef4b 100644 (file)
@@ -568,3 +568,17 @@ Removed
   <https://github.com/python/pythoncapi-compat/>`_ can be used to get this
   function on Python 3.8 and older.
   (Contributed by Victor Stinner in :gh:`105268`.)
+
+* Remove the old aliases to functions calling functions which were kept for
+  backward compatibility with Python 3.8 provisional API:
+
+  * ``_PyObject_CallMethodNoArgs()``: use ``PyObject_CallMethodNoArgs()``
+  * ``_PyObject_CallMethodOneArg()``: use ``PyObject_CallMethodOneArg()``
+  * ``_PyObject_CallOneArg()``: use ``PyObject_CallOneArg()``
+  * ``_PyObject_FastCallDict()``: use ``PyObject_VectorcallDict()``
+  * ``_PyObject_Vectorcall()``: use ``PyObject_Vectorcall()``
+  * ``_PyObject_VectorcallMethod()``: use ``PyObject_VectorcallMethod()``
+  * ``_PyVectorcall_Function()``: use ``PyVectorcall_Function()``
+
+  Just remove the underscore prefix to update your code.
+  (Contributed by Victor Stinner in :gh:`106084`.)
index 992dd068db90ea6eb06e76a812a0c8bb8362c926..abae3e4f72e97af021ba78eda8fa546f7a6dcbbf 100644 (file)
@@ -58,15 +58,6 @@ _PyVectorcall_NARGS(size_t n)
 
 PyAPI_FUNC(vectorcallfunc) PyVectorcall_Function(PyObject *callable);
 
-// Backwards compatibility aliases for API that was provisional in Python 3.8
-#define _PyObject_Vectorcall PyObject_Vectorcall
-#define _PyObject_VectorcallMethod PyObject_VectorcallMethod
-#define _PyObject_FastCallDict PyObject_VectorcallDict
-#define _PyVectorcall_Function PyVectorcall_Function
-#define _PyObject_CallOneArg PyObject_CallOneArg
-#define _PyObject_CallMethodNoArgs PyObject_CallMethodNoArgs
-#define _PyObject_CallMethodOneArg PyObject_CallMethodOneArg
-
 /* Same as PyObject_Vectorcall except that keyword arguments are passed as
    dict, which may be NULL if there are no keyword arguments. */
 PyAPI_FUNC(PyObject *) PyObject_VectorcallDict(
diff --git a/Misc/NEWS.d/next/C API/2023-06-25-18-01-27.gh-issue-106084.PEzqU3.rst b/Misc/NEWS.d/next/C API/2023-06-25-18-01-27.gh-issue-106084.PEzqU3.rst
new file mode 100644 (file)
index 0000000..b430f5f
--- /dev/null
@@ -0,0 +1,13 @@
+Remove the old aliases to functions calling functions which were kept for
+backward compatibility with Python 3.8 provisional API:
+
+* ``_PyObject_CallMethodNoArgs()``: use ``PyObject_CallMethodNoArgs()``
+* ``_PyObject_CallMethodOneArg()``: use ``PyObject_CallMethodOneArg()``
+* ``_PyObject_CallOneArg()``: use ``PyObject_CallOneArg()``
+* ``_PyObject_FastCallDict()``: use ``PyObject_VectorcallDict()``
+* ``_PyObject_Vectorcall()``: use ``PyObject_Vectorcall()``
+* ``_PyObject_VectorcallMethod()``: use ``PyObject_VectorcallMethod()``
+* ``_PyVectorcall_Function()``: use ``PyVectorcall_Function()``
+
+Just remove the underscore prefix to update your code. Patch by Victor
+Stinner.
index a8001d71223fdc912969638d6b34af2a9ba4bb41..aa566c31cc1eaa23e61d0f91104f357247972096 100644 (file)
@@ -276,7 +276,7 @@ partial_vectorcall(partialobject *pto, PyObject *const *args,
 static void
 partial_setvectorcall(partialobject *pto)
 {
-    if (_PyVectorcall_Function(pto->fn) == NULL) {
+    if (PyVectorcall_Function(pto->fn) == NULL) {
         /* Don't use vectorcall if the underlying function doesn't support it */
         pto->vectorcall = NULL;
     }
index 2b98bb5ae58bc6cd81b217f93cf74a4760421ccf..1070a751ffe638018a0dd8ee9f637365f7e9786d 100644 (file)
@@ -1715,7 +1715,7 @@ mbstreamwriter_iwrite(MultibyteStreamWriterObject *self,
     if (str == NULL)
         return -1;
 
-    wr = _PyObject_CallMethodOneArg(self->stream, str_write, str);
+    wr = PyObject_CallMethodOneArg(self->stream, str_write, str);
     Py_DECREF(str);
     if (wr == NULL)
         return -1;
@@ -1826,7 +1826,7 @@ _multibytecodec_MultibyteStreamWriter_reset_impl(MultibyteStreamWriterObject *se
     if (PyBytes_Size(pwrt) > 0) {
         PyObject *wr;
 
-        wr = _PyObject_CallMethodOneArg(self->stream, state->str_write, pwrt);
+        wr = PyObject_CallMethodOneArg(self->stream, state->str_write, pwrt);
         if (wr == NULL) {
             Py_DECREF(pwrt);
             return NULL;
index 40eccefb4a6c8d6cbf32465bc6d4b46850ae0c3f..fc8a6f9e0a022837cf810eee8ee78e22153b5fce 100644 (file)
@@ -122,7 +122,7 @@ _PyObject_FastCallDictTstate(PyThreadState *tstate, PyObject *callable,
     assert(nargs == 0 || args != NULL);
     assert(kwargs == NULL || PyDict_Check(kwargs));
 
-    vectorcallfunc func = _PyVectorcall_Function(callable);
+    vectorcallfunc func = PyVectorcall_Function(callable);
     if (func == NULL) {
         /* Use tp_call instead */
         return _PyObject_MakeTpCall(tstate, callable, args, nargs, kwargs);
@@ -349,7 +349,7 @@ _PyObject_Call(PyThreadState *tstate, PyObject *callable,
     assert(PyTuple_Check(args));
     assert(kwargs == NULL || PyDict_Check(kwargs));
     EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, callable);
-    vectorcallfunc vector_func = _PyVectorcall_Function(callable);
+    vectorcallfunc vector_func = PyVectorcall_Function(callable);
     if (vector_func != NULL) {
         return _PyVectorcall_Call(tstate, vector_func, callable, args, kwargs);
     }
index 72ac470394926225d8c71f0a582e66f1ba0a0112..98d8698fa70fbca66c5015390145893d99723e14 100644 (file)
@@ -1110,9 +1110,9 @@ mappingproxy_get(mappingproxyobject *pp, PyObject *const *args, Py_ssize_t nargs
     {
         return NULL;
     }
-    return _PyObject_VectorcallMethod(&_Py_ID(get), newargs,
-                                        3 | PY_VECTORCALL_ARGUMENTS_OFFSET,
-                                        NULL);
+    return PyObject_VectorcallMethod(&_Py_ID(get), newargs,
+                                     3 | PY_VECTORCALL_ARGUMENTS_OFFSET,
+                                     NULL);
 }
 
 static PyObject *
index eab6503046b5ccac94bd8aa216806ff87ec06a56..b1a9858d82f7d61f4fefd7183c4143f8996df411 100644 (file)
@@ -1485,7 +1485,7 @@ write_unraisable_exc_file(PyThreadState *tstate, PyObject *exc_type,
     }
 
     /* Explicitly call file.flush() */
-    PyObject *res = _PyObject_CallMethodNoArgs(file, &_Py_ID(flush));
+    PyObject *res = PyObject_CallMethodNoArgs(file, &_Py_ID(flush));
     if (!res) {
         return -1;
     }
index 97da8bba8adff91f572dd86fc27a46ba3b33be33..b3699bdec994d6cc872753aba3ec60bb521c6053 100644 (file)
@@ -278,7 +278,7 @@ import_ensure_initialized(PyInterpreterState *interp, PyObject *mod, PyObject *n
     Py_XDECREF(spec);
     if (busy) {
         /* Wait until module is done importing. */
-        PyObject *value = _PyObject_CallMethodOneArg(
+        PyObject *value = PyObject_CallMethodOneArg(
             IMPORTLIB(interp), &_Py_ID(_lock_unlock_module), name);
         if (value == NULL) {
             return -1;
@@ -1660,7 +1660,7 @@ PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co,
         external= PyObject_GetAttrString(IMPORTLIB(interp),
                                          "_bootstrap_external");
         if (external != NULL) {
-            pathobj = _PyObject_CallMethodOneArg(
+            pathobj = PyObject_CallMethodOneArg(
                 external, &_Py_ID(_get_sourcefile), cpathobj);
             Py_DECREF(external);
         }
index 352976b1d69f04f4ba04a6e2190b9d7211c9d879..972a13876e626b3705764ebdc5c2d7c8a5d891f4 100644 (file)
@@ -1707,7 +1707,7 @@ marshal_dump_impl(PyObject *module, PyObject *value, PyObject *file,
     s = PyMarshal_WriteObjectToString(value, version);
     if (s == NULL)
         return NULL;
-    res = _PyObject_CallMethodOneArg(file, &_Py_ID(write), s);
+    res = PyObject_CallMethodOneArg(file, &_Py_ID(write), s);
     Py_DECREF(s);
     return res;
 }
index 1ec21440c7abad4c44c1b89969f66aae210e0f57..26e474a3efefd1a0dfae56c2484a0b593da116f3 100644 (file)
@@ -1565,7 +1565,7 @@ _PyErr_Display(PyObject *file, PyObject *unused, PyObject *value, PyObject *tb)
     Py_XDECREF(ctx.seen);
 
     /* Call file.flush() */
-    PyObject *res = _PyObject_CallMethodNoArgs(file, &_Py_ID(flush));
+    PyObject *res = PyObject_CallMethodNoArgs(file, &_Py_ID(flush));
     if (!res) {
         /* Silently ignore file.flush() error */
         PyErr_Clear();
@@ -1677,7 +1677,7 @@ flush_io_stream(PyThreadState *tstate, PyObject *name)
 {
     PyObject *f = _PySys_GetAttr(tstate, name);
     if (f != NULL) {
-        PyObject *r = _PyObject_CallMethodNoArgs(f, &_Py_ID(flush));
+        PyObject *r = PyObject_CallMethodNoArgs(f, &_Py_ID(flush));
         if (r) {
             Py_DECREF(r);
         }
index f5d4711b0c2c9261dd87d525a4cc29ccb2a877ad..3284e14e7742db5e49c9c6693adc9786ceafe972 100644 (file)
@@ -3756,7 +3756,7 @@ sys_pyfile_write_unicode(PyObject *unicode, PyObject *file)
     if (file == NULL)
         return -1;
     assert(unicode != NULL);
-    PyObject *result = _PyObject_CallMethodOneArg(file, &_Py_ID(write), unicode);
+    PyObject *result = PyObject_CallMethodOneArg(file, &_Py_ID(write), unicode);
     if (result == NULL) {
         return -1;
     }