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

Unable to call QtCore.QObject.__new__ in Python 2.7

    Details

    • Type: Bug
    • Status: In Progress
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: 5.12.4, 5.13.0
    • Fix Version/s: 5.13.1
    • Component/s: PySide, Shiboken
    • Labels:
      None
    • Platform/s:
      All

      Description

      We have a singleton metaclass based on type(QtCore.QObject) in the __call__
      method we create a new instance of the class and return it

      def __call__(self, *args, **kwargs):
          instance = self.__new__(self, *args, **kwargs)
          instance.__init__(*args, **kwargs)
          return instance

      or, if you want the one-liner version:

      QtCore.QObject.__new__(QtCore.QObject, "", (), {})

      the error obtained running this code on Python2 is:

      TypeError: PySide2.QtCore.QObject.__new__(PySide2.QtCore.QObject) is not safe, use object.__new__()

      the same one-liner works on Python3, I think it is related to PYSIDE-816 and heap types.

        Attachments

          Issue Links

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

            Activity

              People

              • Assignee:
                ctismer Christian Tismer
                Reporter:
                qtlavoratore Nicolo' Cristini
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes