Skip to content
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

PyQt6 uses PySequence_Fast() which was removed from the limited C API 3.14 #130947

Open
vstinner opened this issue Mar 7, 2025 · 3 comments
Open
Labels
3.14 new features, bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-bug An unexpected behavior, bug, or error

Comments

@vstinner
Copy link
Member

vstinner commented Mar 7, 2025

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

@vstinner vstinner added the type-bug An unexpected behavior, bug, or error label Mar 7, 2025
@vstinner
Copy link
Member Author

vstinner commented Mar 7, 2025

Fedora downstream issue: https://bugzilla.redhat.com/show_bug.cgi?id=2345504

vstinner added a commit to vstinner/cpython that referenced this issue Mar 7, 2025
Add again PySequence_Fast(), PySequence_Fast_GET_SIZE() and
PySequence_Fast_GET_ITEM() to the limited C API

Add an unit tests.
@ZeroIntensity ZeroIntensity added topic-C-API 3.14 new features, bugs and security fixes labels Mar 7, 2025
@rhettinger
Copy link
Contributor

Can PyQt6 project can add an #ifdef to avoid a conflict? The Py... is supposed to be ours and not for downstream users.

Also, +1 for adding back PySequence_Fast(). I've found it to be pretty useful. Presumably the PyQt maintainers also found it to be so useful that they had to reimplement it.

@vstinner
Copy link
Member Author

vstinner commented Mar 7, 2025

Can PyQt6 project can add an #ifdef to avoid a conflict? The Py... is supposed to be ours and not for downstream users.

Which conflict? PyQt6 defines Sequence_Fast_Size() and Sequence_Fast_GetItem() macros: without Py prefix.

@picnixz picnixz added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 new features, bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants