]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-91417: Remove PySequence_Fast() from the limited C API (#129398)
authorVictor Stinner <vstinner@python.org>
Sun, 2 Feb 2025 22:17:30 +0000 (23:17 +0100)
committerGitHub <noreply@github.com>
Sun, 2 Feb 2025 22:17:30 +0000 (23:17 +0100)
The function never worked with the limited C API. It was added by
mistake.

Doc/data/stable_abi.dat
Doc/whatsnew/3.14.rst
Include/abstract.h
Include/cpython/abstract.h
Misc/NEWS.d/next/C_API/2025-01-28-13-21-17.gh-issue-91417.AfiR0t.rst [new file with mode: 0644]
Misc/stable_abi.toml

index c15f82603aa94432369077660214dcf75c1ee8c0..59e7a31bc2ef06613ab49498193e46e9d4d52dc1 100644 (file)
@@ -582,7 +582,6 @@ func,PySequence_Contains,3.2,,
 func,PySequence_Count,3.2,,
 func,PySequence_DelItem,3.2,,
 func,PySequence_DelSlice,3.2,,
-func,PySequence_Fast,3.2,,
 func,PySequence_GetItem,3.2,,
 func,PySequence_GetSlice,3.2,,
 func,PySequence_In,3.2,,
index daed0e8aa509a102ee2dfa3dd31427aa2f42f41f..59c432d30a342be2e9f6fc94d9937219a5f35cc6 100644 (file)
@@ -1343,6 +1343,11 @@ Limited C API changes
   implementation details.
   (Contributed by Victor Stinner in :gh:`120600` and :gh:`124127`.)
 
+* Remove :c:func:`PySequence_Fast` from the limited C API, since this function
+  has to be used with :c:macro:`PySequence_Fast_GET_ITEM` which never worked
+  in the limited C API.
+  (Contributed by Victor Stinner in :gh:`91417`.)
+
 
 Porting to Python 3.14
 ----------------------
index 7cfee1332ccaa4f4a6914a7f3824462292ca0c75..4efe4fcb01490351b4ae42c85433edfc4c248f95 100644 (file)
@@ -726,31 +726,6 @@ PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o);
    This is equivalent to the Python expression: list(o) */
 PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o);
 
-/* Return the sequence 'o' as a list, unless it's already a tuple or list.
-
-   Use PySequence_Fast_GET_ITEM to access the members of this list, and
-   PySequence_Fast_GET_SIZE to get its length.
-
-   Returns NULL on failure.  If the object does not support iteration, raises a
-   TypeError exception with 'm' as the message text. */
-PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
-
-/* Return the size of the sequence 'o', assuming that 'o' was returned by
-   PySequence_Fast and is not NULL. */
-#define PySequence_Fast_GET_SIZE(o) \
-    (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
-
-/* Return the 'i'-th element of the sequence 'o', assuming that o was returned
-   by PySequence_Fast, and that i is within bounds. */
-#define PySequence_Fast_GET_ITEM(o, i)\
-     (PyList_Check(o) ? PyList_GET_ITEM((o), (i)) : PyTuple_GET_ITEM((o), (i)))
-
-/* Return a pointer to the underlying item array for
-   an object returned by PySequence_Fast */
-#define PySequence_Fast_ITEMS(sf) \
-    (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \
-                      : ((PyTupleObject *)(sf))->ob_item)
-
 /* Return the number of occurrences on value on 'o', that is, return
    the number of keys for which o[key] == value.
 
index 4e7b7a46703a6d08a3d73b16d1bfb7e164d53afb..8fed1d3110988b1ebe984dc203ff852a537993b8 100644 (file)
@@ -85,3 +85,29 @@ PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
    need to be corrected for a negative index. */
 #define PySequence_ITEM(o, i)\
     ( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) )
+
+/* Return the sequence 'o' as a list, unless it's already a tuple or list.
+
+   Use PySequence_Fast_GET_ITEM to access the members of this list, and
+   PySequence_Fast_GET_SIZE to get its length.
+
+   Returns NULL on failure.  If the object does not support iteration, raises a
+   TypeError exception with 'm' as the message text. */
+PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
+
+/* Return the size of the sequence 'o', assuming that 'o' was returned by
+   PySequence_Fast and is not NULL. */
+#define PySequence_Fast_GET_SIZE(o) \
+    (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
+
+/* Return the 'i'-th element of the sequence 'o', assuming that o was returned
+   by PySequence_Fast, and that i is within bounds. */
+#define PySequence_Fast_GET_ITEM(o, i)\
+     (PyList_Check(o) ? PyList_GET_ITEM((o), (i)) : PyTuple_GET_ITEM((o), (i)))
+
+/* Return a pointer to the underlying item array for
+   an object returned by PySequence_Fast */
+#define PySequence_Fast_ITEMS(sf) \
+    (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \
+                      : ((PyTupleObject *)(sf))->ob_item)
+
diff --git a/Misc/NEWS.d/next/C_API/2025-01-28-13-21-17.gh-issue-91417.AfiR0t.rst b/Misc/NEWS.d/next/C_API/2025-01-28-13-21-17.gh-issue-91417.AfiR0t.rst
new file mode 100644 (file)
index 0000000..e101718
--- /dev/null
@@ -0,0 +1,3 @@
+Remove :c:func:`PySequence_Fast` from the limited C API, since this function
+has to be used with :c:macro:`PySequence_Fast_GET_ITEM` which never worked
+in the limited C API. Patch by Victor Stinner.
index 276526a1b6908e54a1fcd2c8bc4a091d5ea1ef2f..9317be605f00659f18c696f4697779c1615ad202 100644 (file)
     added = '3.2'
 [function.PySequence_Fast]
     added = '3.2'
+    abi_only = true
 [function.PySequence_GetItem]
     added = '3.2'
 [function.PySequence_GetSlice]