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

regression qt 6.2.1 / 6.2.2 - cannot use inspect module on own types anymore

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Not Evaluated
    • None
    • 6.2.2
    • PySide, Shiboken
    • None
    • Linux/X11

    Description

      Hello,

      we are generating documentation/ stub files to our module by inspecting 'imported' (scriptable-app style) module.

      docs are generated with the help of doxygen xml files.

      in qt 6.2.1 we were able to use python's inspect on our own 'wrapped' classess however in qt 6.2.2 it crashes.

       

      we are using a little patches in order for this to work (qt 6.2.1) :

      pyside-setup/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py:

      @@ -176,6 +177,10 @@
       
           @staticmethod
           def module_valid(mod):
      +        modName = getattr(mod, "__name__", "")
      +        if modName == "AppLib":
      +            return True
      +
               if getattr(mod, "__file__", None) and not Path(mod.__file__).is_dir():
                   ending = Path(mod.__file__).suffix
                   return ending not in (".py", ".pyc", ".pyo", ".pyi")
      

      pyside-setup/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py:

      @@ -224,7 +224,7 @@
       
       def _resolve_value(thing, valtype, line):
           if thing in ("0", "None") and valtype:
      -        if valtype.startswith("PySide6.") or valtype.startswith("typing."):
      +        if valtype.startswith("PySide6.") or valtype.startswith("AppLib.") or valtype.startswith("typing."):
                   return None
               map = type_map[valtype]
               # typing.Any: '_SpecialForm' object has no attribute '__name__'
      

      and here is the code that does not work:

      from PySide6.QtGui import QColor
      for member in inspect.getmembers(QColor):   # this works in both qt 6.2.1. and 6.2.2
          print(f"member: {member}")
      for member in inspect.getmembers(AppLib.GuiChart): # this works only in 6.2.1 and not in 6.2.2
          print(f"member: {member}")
      

      in 6.2.2 it prints to the console:

      Traceback (most recent call last):
        File "<string>", line 1202, in <module>
        File "<string>", line 1150, in genDoc
        File "<string>", line 225, in getParsedInitTypeData
        File "<string>", line 128, in classHasInitFunc
        File "/media/data/devel/ngstock/ngstock-dev/bin/python/env/lib/python3.9/inspect.py", line 351, in getmembers
          value = getattr(object, key)
      SystemError: null argument to internal routine
      

      if not for our sphinx doc / stub file generator everything works good (module / wrapped classes) - just like it used to in 6.2.1

       

      i understand that this may be not a supported by you oficially usage however this was working good in qt 5.15 - 6.2.1 -  i didnt expect to have breakage on a point release. (even 5.15 -> 6.2 required minimal changes)

       

      it was changed on purpose or is it some kind of a bug?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ctismer Christian Tismer
            meomic Michal M
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes