Skip to content

Commit 4ed63c9

Browse files
committed
Revert "pythongh-93274: Expose receiving vectorcall in the Limited API (pythonGH-95717)"
This reverts commit 656dad7.
1 parent 63140b4 commit 4ed63c9

File tree

18 files changed

+13
-152
lines changed

18 files changed

+13
-152
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.12.rst

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -426,22 +426,14 @@ New Features
426426
an additional metaclass argument.
427427
(Contributed by Wenzel Jakob in :gh:`93012`.)
428428

429-
* API for creating objects that can be called using
430-
:ref:`the vectorcall protocol <vectorcall>` was added to the
431-
:ref:`Limited API <stable>`:
432-
433-
* :const:`Py_TPFLAGS_HAVE_VECTORCALL`
434-
* :c:func:`PyVectorcall_NARGS`
435-
* :c:func:`PyVectorcall_Call`
436-
* :c:type:`vectorcallfunc`
437-
429+
* (XXX: this should be combined with :gh:`93274` when that is done)
438430
The :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag is now removed from a class
439431
when the class's :py:meth:`~object.__call__` method is reassigned.
440432
This makes vectorcall safe to use with mutable types (i.e. heap types
441433
without the :const:`immutable <Py_TPFLAGS_IMMUTABLETYPE>` flag).
442434
Mutable types that do not override :c:member:`~PyTypeObject.tp_call` now
443-
inherit the ``Py_TPFLAGS_HAVE_VECTORCALL`` flag.
444-
(Contributed by Petr Viktorin in :gh:`93274`.)
435+
inherit the :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag.
436+
(Contributed by Petr Viktorin in :gh:`93012`.)
445437

446438
Porting to Python 3.12
447439
----------------------

Include/abstract.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,6 @@ PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(
228228
PyObject *name,
229229
...);
230230

231-
/* Given a vectorcall nargsf argument, return the actual number of arguments.
232-
* (For use outside the limited API, this is re-defined as a static inline
233-
* function in cpython/abstract.h)
234-
*/
235-
PyAPI_FUNC(Py_ssize_t) PyVectorcall_NARGS(size_t nargsf);
236-
237-
/* Call "callable" (which must support vectorcall) with positional arguments
238-
"tuple" and keyword arguments "dict". "dict" may also be NULL */
239-
PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict);
240-
241231

242232
/* Implemented elsewhere:
243233

Include/cpython/abstract.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,8 @@ PyAPI_FUNC(PyObject *) _PyObject_MakeTpCall(
5353
#define PY_VECTORCALL_ARGUMENTS_OFFSET \
5454
(_Py_STATIC_CAST(size_t, 1) << (8 * sizeof(size_t) - 1))
5555

56-
// PyVectorcall_NARGS() is exported as a function for the stable ABI.
57-
// Here (when we are not using the stable ABI), the name is overridden to
58-
// call a static inline function for best performance.
59-
#define PyVectorcall_NARGS(n) _PyVectorcall_NARGS(n)
6056
static inline Py_ssize_t
61-
_PyVectorcall_NARGS(size_t n)
57+
PyVectorcall_NARGS(size_t n)
6258
{
6359
return n & ~PY_VECTORCALL_ARGUMENTS_OFFSET;
6460
}
@@ -88,6 +84,10 @@ PyAPI_FUNC(PyObject *) PyObject_VectorcallDict(
8884
size_t nargsf,
8985
PyObject *kwargs);
9086

87+
/* Call "callable" (which must support vectorcall) with positional arguments
88+
"tuple" and keyword arguments "dict". "dict" may also be NULL */
89+
PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict);
90+
9191
// Same as PyObject_Vectorcall(), except without keyword arguments
9292
PyAPI_FUNC(PyObject *) _PyObject_FastCall(
9393
PyObject *func,

Include/cpython/object.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ typedef struct _Py_Identifier {
5454
typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
5555
typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
5656

57+
typedef PyObject *(*vectorcallfunc)(PyObject *callable, PyObject *const *args,
58+
size_t nargsf, PyObject *kwnames);
59+
5760

5861
typedef struct {
5962
/* Number implementations must check *both*

Include/object.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,6 @@ typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
228228
typedef PyObject *(*newfunc)(PyTypeObject *, PyObject *, PyObject *);
229229
typedef PyObject *(*allocfunc)(PyTypeObject *, Py_ssize_t);
230230

231-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000 // 3.12
232-
typedef PyObject *(*vectorcallfunc)(PyObject *callable, PyObject *const *args,
233-
size_t nargsf, PyObject *kwnames);
234-
#endif
235-
236231
typedef struct{
237232
int slot; /* slot id, see below */
238233
void *pfunc; /* function pointer */
@@ -386,13 +381,11 @@ given type object has a specified feature.
386381
#define Py_TPFLAGS_BASETYPE (1UL << 10)
387382

388383
/* Set if the type implements the vectorcall protocol (PEP 590) */
389-
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000
390-
#define Py_TPFLAGS_HAVE_VECTORCALL (1UL << 11)
391384
#ifndef Py_LIMITED_API
385+
#define Py_TPFLAGS_HAVE_VECTORCALL (1UL << 11)
392386
// Backwards compatibility alias for API that was provisional in Python 3.8
393387
#define _Py_TPFLAGS_HAVE_VECTORCALL Py_TPFLAGS_HAVE_VECTORCALL
394388
#endif
395-
#endif
396389

397390
/* Set if the type is 'ready' -- fully initialized */
398391
#define Py_TPFLAGS_READY (1UL << 12)

Lib/test/test_call.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,11 +759,6 @@ def __call__(self, *args):
759759
self.assertEqual(expected, meth(*args1, **kwargs))
760760
self.assertEqual(expected, wrapped(*args, **kwargs))
761761

762-
def test_vectorcall_limited(self):
763-
from _testcapi import pyobject_vectorcall
764-
obj = _testcapi.LimitedVectorCallClass()
765-
self.assertEqual(pyobject_vectorcall(obj, (), ()), "vectorcall called")
766-
767762

768763
class A:
769764
def method_two_args(self, x, y):

Lib/test/test_stable_abi_ctypes.py

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

Misc/NEWS.d/next/C API/2022-08-01-16-21-39.gh-issue-93274.QoDHEu.rst

Lines changed: 0 additions & 3 deletions
This file was deleted.

Misc/stable_abi.toml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,14 +2275,5 @@
22752275
added = '3.11'
22762276
[function.PyErr_SetHandledException]
22772277
added = '3.11'
2278-
22792278
[function.PyType_FromMetaclass]
22802279
added = '3.12'
2281-
[const.Py_TPFLAGS_HAVE_VECTORCALL]
2282-
added = '3.12'
2283-
[function.PyVectorcall_NARGS]
2284-
added = '3.12'
2285-
[function.PyVectorcall_Call]
2286-
added = '3.12'
2287-
[typedef.vectorcallfunc]
2288-
added = '3.12'

Modules/Setup.stdlib.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
@MODULE__XXTESTFUZZ_TRUE@_xxtestfuzz _xxtestfuzz/_xxtestfuzz.c _xxtestfuzz/fuzzer.c
170170
@MODULE__TESTBUFFER_TRUE@_testbuffer _testbuffer.c
171171
@MODULE__TESTINTERNALCAPI_TRUE@_testinternalcapi _testinternalcapi.c
172-
@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/vectorcall_limited.c _testcapi/heaptype.c
172+
@MODULE__TESTCAPI_TRUE@_testcapi _testcapimodule.c _testcapi/vectorcall.c _testcapi/heaptype.c
173173

174174
# Some testing modules MUST be built as shared libraries.
175175
*shared*

Modules/_testcapi/parts.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "Python.h"
22

33
int _PyTestCapi_Init_Vectorcall(PyObject *module);
4-
int _PyTestCapi_Init_VectorcallLimited(PyObject *module);
54
int _PyTestCapi_Init_Heaptype(PyObject *module);

Modules/_testcapi/vectorcall_limited.c

Lines changed: 0 additions & 77 deletions
This file was deleted.

Modules/_testcapimodule.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6865,9 +6865,6 @@ PyInit__testcapi(void)
68656865
if (_PyTestCapi_Init_Vectorcall(m) < 0) {
68666866
return NULL;
68676867
}
6868-
if (_PyTestCapi_Init_VectorcallLimited(m) < 0) {
6869-
return NULL;
6870-
}
68716868
if (_PyTestCapi_Init_Heaptype(m) < 0) {
68726869
return NULL;
68736870
}

Objects/call.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,11 +1047,3 @@ _PyStack_UnpackDict_Free(PyObject *const *stack, Py_ssize_t nargs,
10471047
PyMem_Free((PyObject **)stack - 1);
10481048
Py_DECREF(kwnames);
10491049
}
1050-
1051-
// Export for the stable ABI
1052-
#undef PyVectorcall_NARGS
1053-
Py_ssize_t
1054-
PyVectorcall_NARGS(size_t n)
1055-
{
1056-
return _PyVectorcall_NARGS(n);
1057-
}

PC/python3dll.c

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

PCbuild/_testcapi.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
<ItemGroup>
9696
<ClCompile Include="..\Modules\_testcapimodule.c" />
9797
<ClCompile Include="..\Modules\_testcapi\vectorcall.c" />
98-
<ClCompile Include="..\Modules\_testcapi\vectorcall_limited.c" />
9998
<ClCompile Include="..\Modules\_testcapi\heaptype.c" />
10099
</ItemGroup>
101100
<ItemGroup>

PCbuild/_testcapi.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
<ClCompile Include="..\Modules\_testcapi\vectorcall.c">
1616
<Filter>Source Files</Filter>
1717
</ClCompile>
18-
<ClCompile Include="..\Modules\_testcapi\vectorcall_limited.c">
19-
<Filter>Source Files</Filter>
20-
</ClCompile>
2118
<ClCompile Include="..\Modules\_testcapi\heaptype.c">
2219
<Filter>Source Files</Filter>
2320
</ClCompile>

0 commit comments

Comments
 (0)