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

REG->6.8.0.1: Some subclasses missing when importing * after importing a module

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • 6.8.1, 6.8.0.2
    • 6.8.0.1
    • PySide
    • None
    • 9e2d49988 (dev), b0d9a41cd (6.8), 2e606c31d (6.8.0), 0105ee8fd (tqtc/6.8.0)

    Description

      The following subclasses are missing when importing QtCore, QtGui, and QtWidgets and then importing * from them:

      1. QAbstractEventDispatcher.TimerInfo
      2. QAbstractTextDocumentLayout.PaintContext
      3. QAbstractTextDocumentLayout.Selection
      4. QAccessible.State
      5. QByteArray.FromBase64Result
      6. QCalendar.SystemId
      7. QCalendar.YearMonthDay
      8. QDirListing.DirEntry
      9. QFormLayout.TakeRowResult
      10. QPageRanges.Range
      11. QPainter.PixmapFragment
      12. QPainterPath.Element
      13. QProcess.UnixProcessParameters
      14. QRhiTexture.ViewFormat
      15. QTextEdit.ExtraSelection
      16. QTextLayout.FormatRange

      The following code demonstrates a different behavior when importing a Qt module and not:

      IMPORT_MODULES = False
      
      _init = set(globals())
      if IMPORT_MODULES:
          from PySide6 import QtCore
          from PySide6 import QtGui
          from PySide6 import QtWidgets
      
      from PySide6.QtCore import *
      from PySide6.QtGui import *
      from PySide6.QtWidgets import *
      _imported = set(globals()) - _init
      
      
      def subclasses():
          import enum
      
          for class_name in _imported:
              if class_name[1].isupper() and isinstance((cls:=globals()[class_name]), type):
                  for subclass_name in cls.__dict__:
                      if subclass_name[0].isupper():
                          if isinstance((subclass:=getattr(cls, subclass_name)), type) and enum.Enum not in subclass.__mro__:
                              yield class_name, subclass_name
      
      
      print(sum(1 for _ in subclasses()), "subclasses found")
      print(*sorted(map('.'.join, subclasses())), sep='\n')
      

      With IMPORT_MODULES set to False, it finds 30 non-Enum subclasses, whereas with True, only 14.

      The same behavior takes place when instead of from PySide6 import <module> one does from PySide6.<module> import <something>.

      Attachments

        1. pyside2898.py
          1 kB
          Friedemann Kleint

        Issue Links

          For Gerrit Dashboard: PYSIDE-2898
          # Subject Branch Project Status CR V

          Activity

            People

              ctismer Christian Tismer
              stsav012 Anton Yablokov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes