Python 3.12 segfault with mixin classes

Florian Bruhin me at the-compiler.org
Thu Jun 15 19:03:11 BST 2023


Hey,

> When trying PyQt 6.5.1 with Python 3.12 Beta 2, something like:
> 
>         import sys
>         from PyQt6.QtWidgets import QWidget, QApplication
> 
>         class Mixin: pass
>         class Command(Mixin, QWidget): pass
> 
>         app = QApplication(sys.argv)
>         cmd = Command()
>         cmd.show()
>         app.exec()
> 
> segfaults here on the "cmd.Command()" line:
> 
>         #0  [...] _PyDict_Next (op=0x0, [...])
>         [...]
>         #2  [...]  in trawl_hierarchy([...])
>            from .../lib/python3.12/site-packages/PyQt6/QtCore.abi3.so
>         [...]

Eric Snow commented on the issue:

    Presumably the crashing code is trying to use the dict returned by
    sipPyTypeDict() and I'm guessing that that function basically returns
    pytype->tp_dict and that the pytype in question is a static builtin
    type. If that's the case then the failure makes sense since tp_dict for
    static builtin types is now NULL.

And that indeed seems to be the case: trawl_type does
"dict = sipPyTypeDict(pytype);", that is an alias to sip's
api_py_type_dict, and that accesses py_type->tp_dict.

See:
https://github.com/python/cpython/issues/105227

There is now an open PR to add a PyType_GetDict():
https://github.com/python/cpython/pull/105747

Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230615/f9ea4413/attachment.sig>


More information about the PyQt mailing list