]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106023: Remove _PyObject_FastCall() function (#106265)
authorVictor Stinner <vstinner@python.org>
Fri, 30 Jun 2023 09:46:43 +0000 (11:46 +0200)
committerGitHub <noreply@github.com>
Fri, 30 Jun 2023 09:46:43 +0000 (11:46 +0200)
Doc/whatsnew/3.13.rst
Include/cpython/abstract.h
Lib/test/test_call.py
Lib/test/test_gdb.py
Misc/NEWS.d/next/C API/2023-06-30-09-33-25.gh-issue-106023.YvYiE4.rst [new file with mode: 0644]
Modules/_testcapi/vectorcall.c
Objects/call.c

index c0e9e924c8e82f852cc5badbb28b1078774e6ed5..9696dd4ff0b700d0c34adb4e47d8298536bcd83c 100644 (file)
@@ -597,3 +597,8 @@ Removed
 
   Just remove the underscore prefix to update your code.
   (Contributed by Victor Stinner in :gh:`106084`.)
+
+* Remove private ``_PyObject_FastCall()`` function:
+  use ``PyObject_Vectorcall()`` which is available since Python 3.8
+  (:pep:`590`).
+  (Contributed by Victor Stinner in :gh:`106023`.)
index d563d1b29ac3b3465aabbff8ac62bad0edfa5e10..dd924dfd3d8fcc81ed01992378f1bf7ad9fd20f7 100644 (file)
@@ -24,12 +24,6 @@ PyAPI_FUNC(PyObject *) PyObject_VectorcallDict(
     size_t nargsf,
     PyObject *kwargs);
 
-// Same as PyObject_Vectorcall(), except without keyword arguments
-PyAPI_FUNC(PyObject *) _PyObject_FastCall(
-    PyObject *func,
-    PyObject *const *args,
-    Py_ssize_t nargs);
-
 PyAPI_FUNC(PyObject *) PyObject_CallOneArg(PyObject *func, PyObject *arg);
 
 static inline PyObject *
index 5410131a7dfd891ad480ce2571e5da207d4a331f..09a531f8cc627b044bdbcd0a9ef38891be20b3ee 100644 (file)
@@ -519,19 +519,6 @@ class FastCallTests(unittest.TestCase):
                 expected = (*expected[:-1], result[-1])
         self.assertEqual(result, expected)
 
-    def test_fastcall(self):
-        # Test _PyObject_FastCall()
-
-        for func, args, expected in self.CALLS_POSARGS:
-            with self.subTest(func=func, args=args):
-                result = _testcapi.pyobject_fastcall(func, args)
-                self.check_result(result, expected)
-
-                if not args:
-                    # args=NULL, nargs=0
-                    result = _testcapi.pyobject_fastcall(func, None)
-                    self.check_result(result, expected)
-
     def test_vectorcall_dict(self):
         # Test PyObject_VectorcallDict()
 
@@ -945,11 +932,11 @@ class TestRecursion(unittest.TestCase):
 
         def c_recurse(n):
             if n:
-                _testcapi.pyobject_fastcall(c_recurse, (n-1,))
+                _testcapi.pyobject_vectorcall(c_recurse, (n-1,), ())
 
         def c_py_recurse(m):
             if m:
-                _testcapi.pyobject_fastcall(py_recurse, (1000, m))
+                _testcapi.pyobject_vectorcall(py_recurse, (1000, m), ())
 
         depth = sys.getrecursionlimit()
         sys.setrecursionlimit(100_000)
index 311a864a52387d2a4acf7a7d10ec12462a9a551a..85009089f21d2f7e4b36986855bfdc213239f927 100644 (file)
@@ -729,13 +729,13 @@ class PyListTests(DebuggerTests):
 
 SAMPLE_WITH_C_CALL = """
 
-from _testcapi import pyobject_fastcall
+from _testcapi import pyobject_vectorcall
 
 def foo(a, b, c):
     bar(a, b, c)
 
 def bar(a, b, c):
-    pyobject_fastcall(baz, (a, b, c))
+    pyobject_vectorcall(baz, (a, b, c), None)
 
 def baz(*args):
     id(42)
@@ -756,7 +756,7 @@ class StackNavigationTests(DebuggerTests):
         self.assertMultilineMatches(bt,
                                     r'''^.*
 #[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
-#[0-9]+ <built-in method pyobject_fastcall of module object at remote 0x[0-9a-f]+>
+#[0-9]+ <built-in method pyobject_vectorcall of module object at remote 0x[0-9a-f]+>
 $''')
 
     @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
@@ -785,7 +785,7 @@ $''')
         self.assertMultilineMatches(bt,
                                     r'''^.*
 #[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
-#[0-9]+ <built-in method pyobject_fastcall of module object at remote 0x[0-9a-f]+>
+#[0-9]+ <built-in method pyobject_vectorcall of module object at remote 0x[0-9a-f]+>
 #[0-9]+ Frame 0x-?[0-9a-f]+, for file <string>, line 12, in baz \(args=\(1, 2, 3\)\)
 $''')
 
diff --git a/Misc/NEWS.d/next/C API/2023-06-30-09-33-25.gh-issue-106023.YvYiE4.rst b/Misc/NEWS.d/next/C API/2023-06-30-09-33-25.gh-issue-106023.YvYiE4.rst
new file mode 100644 (file)
index 0000000..3130feb
--- /dev/null
@@ -0,0 +1,2 @@
+Remove private ``_PyObject_FastCall()`` function: use ``PyObject_Vectorcall()``
+which is available since Python 3.8 (:pep:`590`). Patch by Victor Stinner.
index dcbc973c9fb991a8a8059a5acc0afc90e589c254..4935fd1b6a7ba376fcdaf3c2158b306e8a239b5d 100644 (file)
@@ -26,23 +26,6 @@ fastcall_args(PyObject *args, PyObject ***stack, Py_ssize_t *nargs)
 }
 
 
-static PyObject *
-test_pyobject_fastcall(PyObject *self, PyObject *args)
-{
-    PyObject *func, *func_args;
-    PyObject **stack;
-    Py_ssize_t nargs;
-
-    if (!PyArg_ParseTuple(args, "OO", &func, &func_args)) {
-        return NULL;
-    }
-
-    if (fastcall_args(func_args, &stack, &nargs) < 0) {
-        return NULL;
-    }
-    return _PyObject_FastCall(func, stack, nargs);
-}
-
 static PyObject *
 test_pyobject_fastcalldict(PyObject *self, PyObject *args)
 {
@@ -259,7 +242,6 @@ _testcapi_has_vectorcall_flag_impl(PyObject *module, PyTypeObject *type)
 }
 
 static PyMethodDef TestMethods[] = {
-    {"pyobject_fastcall", test_pyobject_fastcall, METH_VARARGS},
     {"pyobject_fastcalldict", test_pyobject_fastcalldict, METH_VARARGS},
     {"pyobject_vectorcall", test_pyobject_vectorcall, METH_VARARGS},
     {"function_setvectorcall", function_setvectorcall, METH_O},
index e745fc41feaac8c70612ef8294ee5dc7c876e715..16c41ffe1d09b57c72377d3ceda1f18ff7f1e5e1 100644 (file)
@@ -327,14 +327,6 @@ PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
 }
 
 
-PyObject *
-_PyObject_FastCall(PyObject *func, PyObject *const *args, Py_ssize_t nargs)
-{
-    PyThreadState *tstate = _PyThreadState_GET();
-    return _PyObject_FastCallTstate(tstate, func, args, nargs);
-}
-
-
 PyObject *
 _PyObject_Call(PyThreadState *tstate, PyObject *callable,
                PyObject *args, PyObject *kwargs)