10000 gh-105107: Remove PyEval_CallFunction() function (#105108) · python/cpython@579c41c · GitHub
[go: up one dir, main page]

Skip to content

Commit 579c41c

Browse files
authored
gh-105107: Remove PyEval_CallFunction() function (#105108)
Remove 4 functions from the C API, deprecated in Python 3.9: * PyEval_CallObjectWithKeywords() * PyEval_CallObject() * PyEval_CallFunction() * PyEval_CallMethod() Keep 3 functions in the stable ABI: * PyEval_CallObjectWithKeywords() * P 10000 yEval_CallFunction() * PyEval_CallMethod()
1 parent adccff3 commit 579c41c

File tree

6 files changed

+34
-32
lines changed

6 files changed

+34
-32
lines changed

Doc/data/stable_abi.dat

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/whatsnew/3.13.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,18 @@ Deprecated
308308
Removed
309309
-------
310310

311+
* Remove functions deprecated in Python 3.9.
312+
313+
* ``PyEval_CallObject()``, ``PyEval_CallObjectWithKeywords()``: use
314+
:c:func:`PyObject_CallNoArgs` or :c:func:`PyObject_Call` instead.
315+
Warning: :c:func:`PyObject_Call` positional arguments must be a
316+
:class:`tuple` and must not be *NULL*, keyword arguments must be a
317+
:class:`dict` or *NULL*, whereas removed functions checked arguments type
318+
and accepted *NULL* positional and keyword arguments.
319+
To replace ``PyEval_CallObjectWithKeywords(func, NULL, kwargs)`` with
320+
:c:func:`PyObject_Call`, pass an empty tuple as positional arguments using
321+
:c:func:`PyTuple_New(0) <PyTuple_New>`.
322+
* ``PyEval_CallFunction()``: use :c:func:`PyObject_CallFunction` instead.
323+
* ``PyEval_CallMethod()``: use :c:func:`PyObject_CallMethod` instead.
324+
325+
(Contributed by Victor Stinner in :gh:`105107`.)

Include/ceval.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,6 @@ PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,
1717
PyObject *const *defs, int defc,
1818
PyObject *kwdefs, PyObject *closure);
1919

20-
/* PyEval_CallObjectWithKeywords(), PyEval_CallObject(), PyEval_CallFunction
21-
* and PyEval_CallMethod are deprecated. Since they are officially part of the
22-
* stable ABI (PEP 384), they must be kept for backward compatibility.
23-
* PyObject_Call(), PyObject_CallFunction() and PyObject_CallMethod() are
24-
* recommended to call a callable object.
25-
*/
26-
27-
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
28-
PyObject *callable,
29-
PyObject *args,
30-
PyObject *kwargs);
31-
32-
/* Deprecated since PyEval_CallObjectWithKeywords is deprecated */
33-
#define PyEval_CallObject(callable, arg) \
34-
PyEval_CallObjectWithKeywords((callable), (arg), _PyObject_CAST(_Py_NULL))
35-
36-
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallFunction(
37-
PyObject *callable, const char *format, ...);
38-
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallMethod(
39-
PyObject *obj, const char *name, const char *format, ...);
40-
4120
PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
4221
PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
4322
PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Remove functions deprecated in Python 3.9.
2+
3+
* ``PyEval_CallObject()``, ``PyEval_CallObjectWithKeywords()``: use
4+
:c:func:`PyObject_CallNoArgs` and :c:func:`PyObject_Call` (positional
5+
arguments must not be *NULL*) instead.
6+
* ``PyEval_CallFunction()``: use :c:func:`PyObject_CallFunction` instead.
7+
* ``PyEval_CallMethod()``: use :c:func:`PyObject_CallMethod` instead.
8+
9+
Patch by Victor Stinner.

Misc/stable_abi.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,10 +667,13 @@
667667
added = '3.2'
668668
[function.PyEval_CallFunction]
669669
added = '3.2'
670+
abi_only = true
670671
[function.PyEval_CallMethod]
671672
added = '3.2'
673+
abi_only = true
672674
[function.PyEval_CallObjectWithKeywords]
673675
added = '3.2'
676+
abi_only = true
674677
[function.PyEval_EvalCode]
675678
added = '3.2'
676679
[function.PyEval_EvalCodeEx]

Objects/call.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,9 @@ _PyFunction_Vectorcall(PyObject *func, PyObject* const* stack,
426426
/* --- More complex call functions -------------------------------- */
427427

428428
/* External interface to call any callable object.
429-
The args must be a tuple or NULL. The kwargs must be a dict or NULL. */
430-
PyObject *
429+
The args must be a tuple or NULL. The kwargs must be a dict or NULL.
430+
Function removed in Python 3.13 API but kept in the stable ABI. */
431+
PyAPI_FUNC(PyObject*)
431432
PyEval_CallObjectWithKeywords(PyObject *callable,
432433
PyObject *args, PyObject *kwargs)
433434
{
@@ -583,9 +584,8 @@ PyObject_CallFunction(PyObject *callable, const char *format, ...)
583584

584585

585586
/* PyEval_CallFunction is exact copy of PyObject_CallFunction.
586-
* This function is kept for backward compatibility.
587-
*/
588-
PyObject *
587+
Function removed in Python 3.13 API but kept in the stable ABI. */
588+
PyAPI_FUNC(PyObject*)
589589
PyEval_CallFunction(PyObject *callable, const char *format, ...)
590590
{
591591
va_list va;
@@ -656,9 +656,8 @@ PyObject_CallMethod(PyObject *obj, const char *name, const char *format, ...)
656656

657657

658658
/* PyEval_CallMethod is exact copy of PyObject_CallMethod.
659-
* This function is kept for backward compatibility.
660-
*/
661 5C99 -
PyObject *
659+
Function removed in Python 3.13 API but kept in the stable ABI. */
660+
PyAPI_FUNC(PyObject*)
662661
PyEval_CallMethod(PyObject *obj, const char *name, const char *format, ...)
663662
{
664663
PyThreadState *tstate = _PyThreadState_GET();

0 commit comments

Comments
 (0)
0