8000 bpo-39245: Make Vectorcall public by encukou · Pull Request #17893 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-39245: Make Vectorcall public #17893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 6, 2020
Prev Previous commit
Next Next commit
Add backcompat defines and move non-limited API declaration to cpython/
This partially reverts commit 2ff58a2
which added PyObject_CallNoArgs to the 3.9+ stable ABI. This should not
be done; there are enough other call APIs in the stable ABI to choose from.
  • Loading branch information
encukou committed Jan 7, 2020
commit f0c005f879e71442cf5c9a52e75b38ff9f0fc823
6 changes: 0 additions & 6 deletions Include/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ extern "C" {
#endif


#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
/* Call a callable Python object without any arguments */
PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func);
#endif


/* Call a callable Python object 'callable' with arguments given by the
tuple 'args' and keywords arguments given by the dictionary 'kwargs'.

Expand Down
11 changes: 11 additions & 0 deletions Include/cpython/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
return _PyObject_VectorcallTstate(tstate, callable,
args, nargsf, kwnames);
}
// 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_FastCallDict
#define _PyVectorcall_Function PyVectorcall_Function
#define _PyObject_CallOneArg PyObject_CallOneArg
#define _PyObject_CallMethodNoArgs PyObject_CallMethodNoArgs
#define _PyObject_CallMethodOneArg PyObject_CallMethodOneArg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, Py_DEPRECATED() cannot be used on these aliases, but I think that it's fine to remove them at once in a future Python release like 3.10 or later. We don't provide any backward compatibility on private functions.

Another option is to not provide this backward compatibility layer and force users to upgrade. Do you know which projects are impacted if these symbols are removed? Does it impact all projects which ship C code generated by Cython?

What about _Py_TPFLAGS_HAVE_VECTORCALL?

Copy link
Member Author
@encukou encukou Jan 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to keep the aliases indefinitely. Would that be a problem?
But you're right, they aren't supported API and we can just remove them in 3.10.
I don't know what projects used them. They were documented for 3.8 (with a warning).

The alias for Py_TPFLAGS_HAVE_VECTORCALL is near its definition.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to keep the aliases indefinitely. Would that be a problem?

Usually, I prefer to remove legacy stuff to reduce the maintenance burden. But these aliases are not an issue in the short term.


/* Same as PyObject_Vectorcall except that keyword arguments are passed as
dict, which may be NULL if there are no keyword arguments. */
Expand Down Expand Up @@ -182,6 +190,9 @@ PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg)
2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
}

/* Call a callable Python object without any arguments */
PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func);

/* Like PyObject_CallMethod(), but expect a _Py_Identifier*
as the method name. */
PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj,
Expand Down
2 changes: 2 additions & 0 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ given type object has a specified feature.
/* Set if the type implements the vectorcall protocol (PEP 590) */
#ifndef Py_LIMITED_API
#define Py_TPFLAGS_HAVE_VECTORCALL (1UL << 11)
// Backwards compatibility alias for API that was provisional in Python 3.8
#define _Py_TPFLAGS_HAVE_VECTORCALL Py_TPFLAGS_HAVE_VECTORCALL
#endif

/* Set if the type is 'ready' -- fully initialized */
Expand Down
0