Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1970

Using __slots__ in PySide subclasses segfaults

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 5.15.4, 6.3.0
    • PySide, Shiboken
    • None
    • Python 3.10
      PySide6 6.3.0
      shiboken6 6.3.0
      Linux
    • d58e262b11 (pyside/pyside-setup/dev) 5ed3e6f5dd (pyside/pyside-setup/6.3) bdfd9e0a50 (pyside/pyside-setup/6.4) 5ed3e6f5dd (pyside/tqtc-pyside-setup/6.3) bdfd9e0a50 (pyside/tqtc-pyside-setup/6.4) bdfd9e0a50 (pyside/tqtc-pyside-setup/tqtc/6.4)

    Description

      Defining __slots__ in a PySide subclass segfaults on attribute assignment

      from PySide6.QtCore import QObject
      
      
      class Obj(QObject):
          __slots__ = ("a",)
      
          def __init__(self, *args, **kwargs):
              super().__init__(*args, **kwargs)
              self.a = 1  # <<< segfaults here
      
      
      obj = Obj()
      

      Note: the __slots__ is python feature unrelated to Qt's signal/slot mechanism.

      https://docs.python.org/3/reference/datamodel.html?highlight=__slots__#object.__slots__

      Attachments

        1. pyside1970.py
          0.6 kB
        2. pyside1970_stack2.txt
          3 kB
        3. pyside1970_stack1.txt
          0.8 kB

        Issue Links

          Activity

            People

              ctismer Christian Tismer
              aleserjavec Ales Erjavec
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: