[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    PyQt6 and invalid enums: QKeySequence/QKeyCombination
From:       Florian Bruhin <me () the-compiler ! org>
Date:       2022-04-28 17:18:21
Message-ID: 20220428171821.5jpgvb3ilymq2ipv () aragog
[Download RAW message or body]


Hey,

I wanted to report another case where I see invalid enum ValueErrors
from PyQt6 without doing anything wrong. Not sure if this changes
anything about the big picture, but maybe it does, given that the
underlying issue is a bit different:

    >>> qkeycombination = QKeySequence("\x80")[0]
    >>> qkeycombination.key()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3.10/enum.py", line 385, in __call__
        return cls.__new__(cls, value)
      File "/usr/lib/python3.10/enum.py", line 710, in __new__
        raise ve_exc
    ValueError: 128 is not a valid Qt.Key

I think Qt.Key is special in that regard because unicode characters
(at least those not represented in the enum) just end up as a
pseudo-member of that enum:
https://github.com/qt/qtbase/blob/v6.3.0/src/corelib/global/qnamespace.h#L677-L682

This seems reflected in some places of the Qt API (I think that's why
e.g. QKeyEvent.key() returns an int, not a Qt.Key), but evidently not in
others (QKeyCombination.key() in this case).

Florian

-- 
            me@the-compiler.org | https://www.qutebrowser.org 
       https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
       GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
             I love long mails! | https://email.is-not-s.ms/

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic