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

Flag inequality gives wrong result when flag object is compared to itself

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 5.15.2, 6.2.0
    • PySide
    • None
    • python 3.9.6
    • Linux/X11
    • 9399408fd1e7e12215389a5bf96ae5e4ec38905b (pyside/pyside-setup/dev) 587b6d15411debf979f2e4e06372e596409eadda (pyside/pyside-setup/6.2) 0de9cda236715bf52b863ea14dc5d4fb824eae5b (pyside/tqtc-pyside-setup/5.15)

    Description

      When storing a combination of flag in a python variable, comparing the flag object to itself gives wrong results with the inequality operator (!=). Interestingly, this only fails with combinations (from my limited tests anyway). More interesting, if you store an equal flag value in a second variable and use that for comparison with the first variable, all is well.

      Code to reproduce:

      from PySide6 import QtCore
      
      if __name__ == '__main__':
          f = QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom
          print('f is f:', f is f)
          # True
          print('f == f:', f == f)
          # True
          print('f != f:', f != f)
          # True -> wrong
      
          g = QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom
          print('f == g:', f == g)
          # True
          print('f != g:', f != g)
          # False
      

      Attachments

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

        Activity

          People

            kleint Friedemann Kleint
            thomas701 Thomas Mc Kay
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes