Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-105107: Remove PyEval_CallFunction() function
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()
* PyEval_CallFunction()
* PyEval_CallMethod()
  • Loading branch information
vstinner committed May 31, 2023
commit a394bbcbda55bad40f6a1c0c518679e5b28e6e8b
3 changes: 0 additions & 3 deletions Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,17 @@ Deprecated
Removed
-------

* Remove functions deprecated in Python 3.9.

* ``PyEval_CallObject()``, ``PyEval_CallObjectWithKeywords()``: use
:c:func:`PyObject_CallNoArgs` or :c:func:`PyObject_Call` instead.
Warning: :c:func:`PyObject_Call` positional arguments must be a
:class:`tuple` and must not be *NULL*, keyword arguments must by a
:class:`dict` or *NULL*, whereas removed functions checked arguments type.
To replace ``PyEval_CallObjectWithKeywords(func, NULL, kwargs)`` with
:c:func:`PyObject_Call`, pass an empty tuple as positional arguments using
:c:func:`PyTuple_New(0) <PyTuple_New>`.
* ``PyEval_CallFunction()``: use :c:func:`PyObject_CallFunction` instead.
* ``PyEval_CallMethod()``: use :c:func:`PyObject_CallMethod` instead.

(Contributed by Victor Stinner in :gh:`105107`.)
21 changes: 0 additions & 21 deletions Include/ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,6 @@ PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,
PyObject *const *defs, int defc,
PyObject *kwdefs, PyObject *closure);

/* PyEval_CallObjectWithKeywords(), PyEval_CallObject(), PyEval_CallFunction
* and PyEval_CallMethod are deprecated. Since they are officially part of the
* stable ABI (PEP 384), they must be kept for backward compatibility.
* PyObject_Call(), PyObject_CallFunction() and PyObject_CallMethod() are
* recommended to call a callable object.
*/

Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
PyObject *callable,
PyObject *args,
PyObject *kwargs);

/* Deprecated since PyEval_CallObjectWithKeywords is deprecated */
#define PyEval_CallObject(callable, arg) \
PyEval_CallObjectWithKeywords((callable), (arg), _PyObject_CAST(_Py_NULL))

Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallFunction(
PyObject *callable, const char *format, ...);
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallMethod(
PyObject *obj, const char *name, const char *format, ...);

PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Remove functions deprecated in Python 3.9.

* ``PyEval_CallObject()``, ``PyEval_CallObjectWithKeywords()``: use
:c:func:`PyObject_CallNoArgs` and :c:func:`PyObject_Call` (positional
arguments must not be *NULL*) instead.
* ``PyEval_CallFunction()``: use :c:func:`PyObject_CallFunction` instead.
* ``PyEval_CallMethod()``: use :c:func:`PyObject_CallMethod` instead.

Patch by Victor Stinner.
3 changes: 3 additions & 0 deletions Misc/stable_abi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,13 @@
added = '3.2'
[function.PyEval_CallFunction]
added = '3.2'
abi_only = true
[function.PyEval_CallMethod]
added = '3.2'
abi_only = true
[function.PyEval_CallObjectWithKeywords]
added = '3.2'
abi_only = true
[function.PyEval_EvalCode]
added = '3.2'
[function.PyEval_EvalCodeEx]
Expand Down
15 changes: 7 additions & 8 deletions Objects/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,9 @@ _PyFunction_Vectorcall(PyObject *func, PyObject* const* stack,
/* --- More complex call functions -------------------------------- */

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


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


/* PyEval_CallMethod is exact copy of PyObject_CallMethod.
* This function is kept for backward compatibility.
*/
PyObject *
Function removed in Python 3.13 API but kept in the stable ABI. */
PyAPI_FUNC(PyObject*)
PyEval_CallMethod(PyObject *obj, const char *name, const char *format, ...)
{
PyThreadState *tstate = _PyThreadState_GET();
Expand Down