Skip to content

Commit 2ad069d

Browse files
authored
gh-91417: Remove PySequence_Fast() from the limited C API (#129398)
The function never worked with the limited C API. It was added by mistake.
1 parent ae47888 commit 2ad069d

File tree

6 files changed

+35
-26
lines changed

6 files changed

+35
-26
lines changed

Doc/data/stable_abi.dat

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/whatsnew/3.14.rst

+5
Original file line numberDiff line numberDiff line change
@@ -1343,6 +1343,11 @@ Limited C API changes
13431343
implementation details.
13441344
(Contributed by Victor Stinner in :gh:`120600` and :gh:`124127`.)
13451345

1346+
* Remove :c:func:`PySequence_Fast` from the limited C API, since this function
1347+
has to be used with :c:macro:`PySequence_Fast_GET_ITEM` which never worked
1348+
in the limited C API.
1349+
(Contributed by Victor Stinner in :gh:`91417`.)
1350+
13461351

13471352
Porting to Python 3.14
13481353
----------------------

Include/abstract.h

-25
Original file line numberDiff line numberDiff line change
@@ -726,31 +726,6 @@ PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o);
726726
This is equivalent to the Python expression: list(o) */
727727
PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o);
728728

729-
/* Return the sequence 'o' as a list, unless it's already a tuple or list.
730-
731-
Use PySequence_Fast_GET_ITEM to access the members of this list, and
732-
PySequence_Fast_GET_SIZE to get its length.
733-
734-
Returns NULL on failure. If the object does not support iteration, raises a
735-
TypeError exception with 'm' as the message text. */
736-
PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
737-
738-
/* Return the size of the sequence 'o', assuming that 'o' was returned by
739-
PySequence_Fast and is not NULL. */
740-
#define PySequence_Fast_GET_SIZE(o) \
741-
(PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
742-
743-
/* Return the 'i'-th element of the sequence 'o', assuming that o was returned
744-
by PySequence_Fast, and that i is within bounds. */
745-
#define PySequence_Fast_GET_ITEM(o, i)\
746-
(PyList_Check(o) ? PyList_GET_ITEM((o), (i)) : PyTuple_GET_ITEM((o), (i)))
747-
748-
/* Return a pointer to the underlying item array for
749-
an object returned by PySequence_Fast */
750-
#define PySequence_Fast_ITEMS(sf) \
751-
(PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \
752-
: ((PyTupleObject *)(sf))->ob_item)
753-
754729
/* Return the number of occurrences on value on 'o', that is, return
755730
the number of keys for which o[key] == value.
756731

Include/cpython/abstract.h

+26
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,29 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
8585
need to be corrected for a negative index. */
8686
#define PySequence_ITEM(o, i)\
8787
( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) )
88+
89+
/* Return the sequence 'o' as a list, unless it's already a tuple or list.
90+
91+
Use PySequence_Fast_GET_ITEM to access the members of this list, and
92+
PySequence_Fast_GET_SIZE to get its length.
93+
94+
Returns NULL on failure. If the object does not support iteration, raises a
95+
TypeError exception with 'm' as the message text. */
96+
PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
97+
98+
/* Return the size of the sequence 'o', assuming that 'o' was returned by
99+
PySequence_Fast and is not NULL. */
100+
#define PySequence_Fast_GET_SIZE(o) \
101+
(PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
102+
103+
/* Return the 'i'-th element of the sequence 'o', assuming that o was returned
104+
by PySequence_Fast, and that i is within bounds. */
105+
#define PySequence_Fast_GET_ITEM(o, i)\
106+
(PyList_Check(o) ? PyList_GET_ITEM((o), (i)) : PyTuple_GET_ITEM((o), (i)))
107+
108+
/* Return a pointer to the underlying item array for
109+
an object returned by PySequence_Fast */
110+
#define PySequence_Fast_ITEMS(sf) \
111+
(PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \
112+
: ((PyTupleObject *)(sf))->ob_item)
113+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove :c:func:`PySequence_Fast` from the limited C API, since this function
2+
has to be used with :c:macro:`PySequence_Fast_GET_ITEM` which never worked
3+
in the limited C API. Patch by Victor Stinner.

Misc/stable_abi.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,7 @@
12531253
added = '3.2'
12541254
[function.PySequence_Fast]
12551255
added = '3.2'
1256+
abi_only = true
12561257
[function.PySequence_GetItem]
12571258
added = '3.2'
12581259
[function.PySequence_GetSlice]

0 commit comments

Comments
 (0)