Visitar URL original
PyQt6 uses PySequence_Fast() which was removed from the limited C API 3.14 · Issue #130947 · python/cpython · GitHub
Skip to content

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

Description

@vstinner

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

Activity

  1. vstinner commented on Mar 7, 2025

    @vstinner
    MemberAuthor
  2. added a commit that references this issue on Mar 7, 2025
  3. rhettinger commented on Mar 7, 2025

    @rhettinger
    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.

  4. vstinner commented on Mar 7, 2025

    @vstinner
    MemberAuthor

    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.

  5. added 2 commits that reference this issue on Mar 13, 2025
  6. vstinner commented on Mar 13, 2025

    @vstinner
    MemberAuthor

    I added back PySequence_Fast() in the limited C API: 10cbd1f.

  7. added a commit that references this issue on Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)topic-C-APItype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions