vstinner · GitHub

Bug report

Bug description:

In the issue #91417 I removed PySequence_Fast(), commit 2ad069d :

Remove PySequence_Fast() from the limited C API. The function never worked with the limited C API. It was added by mistake.

Problem: PyQt6 uses the function! I propose to add back PySequence_Fast() to the limited C API.

PyQt6:

./qpy/QtOpenGL/qpyopengl_attribute_array.cpp:    values = PySequence_Fast(values, "an attribute array must be a sequence");
./qpy/QtOpenGL/qpyopengl_attribute_array.cpp:            itm = PySequence_Fast(itm,
./qpy/QtOpenGL/qpyopengl_uniform_value_array.cpp:    values = PySequence_Fast(values,
./qpy/QtOpenGL/qpyopengl_uniform_value_array.cpp:            itm = PySequence_Fast(itm,
./qpy/QtOpenGL/qpyopengl_value_array.cpp:    PyObject *seq = PySequence_Fast(values,

They reimplemented PySequence_Fast_GET_SIZE() and PySequence_Fast_GET_ITEM() macros which don't work with the limited C API:

// Replacements for the corresponding Python macros that use the limited API.
#define Sequence_Fast_Size(o) \
    (PyList_Check(o) ? PyList_Size(o) : PyTuple_Size(o))
#define Sequence_Fast_GetItem(o, i)\
    (PyList_Check(o) ? PyList_GetItem(o, i) : PyTuple_GetItem(o, i))

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

Read the original on github.com ↗