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

Property decorator with constant=True generates TypeError

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.15.1, 5.15.2
    • Fix Version/s: None
    • Component/s: PySide, Shiboken
    • Environment:
      Python 3.8.6
    • Platform/s:
      Linux/Other display system
    • Commits:
      fbd3ff2256a338a04f08923620216076be64106d (pyside/pyside-setup/dev)

      Description

      PySide2 generates TypeError when use Property decorator with constant=True

      TypeError: A constant property cannot have a WRITE method or a NOTIFY signal.

      To reproduce - prepare the simple class:

      class A(QObject):
          def __init__(self):
              QObject.__init__(self)
              self.val = str("")
      

      when executing python script PySide2 generates TypeError for this code:

      @Property(str, constant=True)
      def variable(self):
           return self.val

      However, when we transform the previous code into this:

      def getVal(self):
          return self.val
      
      variable = Property(str, getVal, constant=True)
      

      It works.

      In PySide 5.15.0 it all works fine but for version 5.15.1 and 5.15.2 the decorator example generates TypeError.

       

        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:
              blooser Mateusz Solnica
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes