← Back to team overview

edubuntu-bugs team mailing list archive

[Bug 2026250] Re: Exception when using cursor keys in edit fields

 

** Description changed:

  When trying to use the left and right cursor keys I get this exception:
- 
  
  calibre, version 6.22.0
  ERROR: Unhandled exception: <b>ValueError</b>:&lt;flag 'KeyboardModifier'&gt;: no members with value 2147483648
  
  calibre 6.22  embedded-python: False
  Linux-6.1.0-7-amd64-x86_64-with-glibc2.37 Linux ('64bit', 'ELF')
  ('Linux', '6.1.0-7-amd64', '#1 SMP PREEMPT_DYNAMIC Debian 6.1.20-1 (2023-03-19)')
  Python 3.11.4
  Interface language: None
  Successfully initialized third party plugins: DeDRM (10, 0, 3) && Find Duplicates (1, 10, 8) && KePub Metadata Reader (3, 4, 3) && KePub Metadata Writer (3, 4, 3) && KePub Output (3, 6, 3) && Kobo Utilities (2, 16, 8) && KoboTouchExtended (3, 6, 3) && Quality Check (1, 13, 4)
  Traceback (most recent call last):
-   File "/usr/lib/calibre/calibre/gui2/widgets.py", line 542, in event
-     ev.modifiers() & ~Qt.KeyboardModifier.KeypadModifier) == Qt.KeyboardModifier.ControlModifier):
-                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   File "/usr/lib/python3.11/enum.py", line 1542, in __invert__
-     self._inverted_ = self.__class__(self._flag_mask_ ^ self._value_)
-                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   File "/usr/lib/python3.11/enum.py", line 711, in __call__
-     return cls.__new__(cls, value)
-            ^^^^^^^^^^^^^^^^^^^^^^^
-   File "/usr/lib/python3.11/enum.py", line 1136, in __new__
-     raise exc
-   File "/usr/lib/python3.11/enum.py", line 1113, in __new__
-     result = cls._missing_(value)
-              ^^^^^^^^^^^^^^^^^^^^
-   File "/usr/lib/python3.11/enum.py", line 1454, in _missing_
-     raise ValueError('%r: no members with value %r' % (cls, unknown))
+   File "/usr/lib/calibre/calibre/gui2/widgets.py", line 542, in event
+     ev.modifiers() & ~Qt.KeyboardModifier.KeypadModifier) == Qt.KeyboardModifier.ControlModifier):
+                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   File "/usr/lib/python3.11/enum.py", line 1542, in __invert__
+     self._inverted_ = self.__class__(self._flag_mask_ ^ self._value_)
+                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   File "/usr/lib/python3.11/enum.py", line 711, in __call__
+     return cls.__new__(cls, value)
+            ^^^^^^^^^^^^^^^^^^^^^^^
+   File "/usr/lib/python3.11/enum.py", line 1136, in __new__
+     raise exc
+   File "/usr/lib/python3.11/enum.py", line 1113, in __new__
+     result = cls._missing_(value)
+              ^^^^^^^^^^^^^^^^^^^^
+   File "/usr/lib/python3.11/enum.py", line 1454, in _missing_
+     raise ValueError('%r: no members with value %r' % (cls, unknown))
  ValueError: <flag 'KeyboardModifier'>: no members with value 2147483648
  
- 
- This seems to be caused by enum changes in Python 3.11. Here is a test with Python 3.10 and Python 3.11:
+ This seems to be caused by enum changes in Python 3.11. Here is a test
+ with Python 3.10 and Python 3.11:
  
  $ docker run --rm -it python:3.10
- Unable to find image 'python:3.10' locally
- 3.10: Pulling from library/python
- d52e4f012db1: Pull complete 
- 7dd206bea61f: Pull complete 
- 2320f9be4a9c: Pull complete 
- 6e5565e0ba8d: Pull complete 
- d3797e13cc41: Pull complete 
- f8108bc94b5f: Pull complete 
- 3d35965ce4db: Pull complete 
- 4459f6d56468: Pull complete 
- Digest: sha256:1b2e0805e24189fbba4e55b9bee89e3c25533cbe4fb71ae151f3e7ae0c9b86c5
- Status: Downloaded newer image for python:3.10
  Python 3.10.12 (main, Jul  4 2023, 05:58:45) [GCC 12.2.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> from PyQt6.QtCore import Qt
  >>> Qt.KeyboardModifier
  <enum 'KeyboardModifier'>
  >>> Qt.KeyboardModifier.KeypadModifier
  <KeyboardModifier.KeypadModifier: 536870912>
  >>> ~Qt.KeyboardModifier.KeypadModifier
  <KeyboardModifier.GroupSwitchModifier|MetaModifier|AltModifier|ControlModifier|ShiftModifier: 1577058304>
- >>> 
+ >>>
  
  $ docker run --rm -it python:3.11
- Unable to find image 'python:3.11' locally
- 3.11: Pulling from library/python
- d52e4f012db1: Already exists 
- 7dd206bea61f: Already exists 
- 2320f9be4a9c: Already exists 
- 6e5565e0ba8d: Already exists 
- d3797e13cc41: Already exists 
- 70f90dfe001b: Pull complete 
- bd75605de417: Pull complete 
- 3d0e1a4b14bc: Pull complete 
- Digest: sha256:b7a504dd0affeb20cf1ba1d3219f854c889c7ad557a2a5a4c4aba19cadd075f1
- Status: Downloaded newer image for python:3.11
  Python 3.11.4 (main, Jul  4 2023, 05:25:16) [GCC 12.2.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> from PyQt6.QtCore import Qt
  >>> Qt.KeyboardModifier
  <flag 'KeyboardModifier'>
  >>> Qt.KeyboardModifier.KeypadModifier
  <KeyboardModifier.KeypadModifier: 536870912>
  >>> ~Qt.KeyboardModifier.KeypadModifier
  Traceback (most recent call last):
-   File "<stdin>", line 1, in <module>
-   File "/usr/local/lib/python3.11/enum.py", line 1542, in __invert__
-     self._inverted_ = self.__class__(self._flag_mask_ ^ self._value_)
-                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   File "/usr/local/lib/python3.11/enum.py", line 711, in __call__
-     return cls.__new__(cls, value)
-            ^^^^^^^^^^^^^^^^^^^^^^^
-   File "/usr/local/lib/python3.11/enum.py", line 1136, in __new__
-     raise exc
-   File "/usr/local/lib/python3.11/enum.py", line 1113, in __new__
-     result = cls._missing_(value)
-              ^^^^^^^^^^^^^^^^^^^^
-   File "/usr/local/lib/python3.11/enum.py", line 1454, in _missing_
-     raise ValueError('%r: no members with value %r' % (cls, unknown))
+   File "<stdin>", line 1, in <module>
+   File "/usr/local/lib/python3.11/enum.py", line 1542, in __invert__
+     self._inverted_ = self.__class__(self._flag_mask_ ^ self._value_)
+                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   File "/usr/local/lib/python3.11/enum.py", line 711, in __call__
+     return cls.__new__(cls, value)
+            ^^^^^^^^^^^^^^^^^^^^^^^
+   File "/usr/local/lib/python3.11/enum.py", line 1136, in __new__
+     raise exc
+   File "/usr/local/lib/python3.11/enum.py", line 1113, in __new__
+     result = cls._missing_(value)
+              ^^^^^^^^^^^^^^^^^^^^
+   File "/usr/local/lib/python3.11/enum.py", line 1454, in _missing_
+     raise ValueError('%r: no members with value %r' % (cls, unknown))
  ValueError: <flag 'KeyboardModifier'>: no members with value 2147483648
  >>>
  
  Note that in both of the above cases I installed PyQt6 with 'pip install
  pyqt6==6.4.2' with docker exec before importing. I'm not sure why
  Qt.KeyboardModifier is an 'enum' in 3.10 and a 'flag' in 3.11, that may
  be caused by PyQt behaving differently depending on the Python version.
  
  I was able to work around the issue by commenting out the two overridden
  event() methods introduced in
  https://github.com/kovidgoyal/calibre/commit/dcf48d9945590db3d74e4928837d99af5ea775a8,
  but they're presumably still necessary for macOS.

-- 
You received this bug notification because you are a member of Edubuntu
Bugsquad, which is subscribed to calibre in Ubuntu.
https://bugs.launchpad.net/bugs/2026250

Title:
  Exception when using cursor keys in edit fields

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/calibre/+bug/2026250/+subscriptions



References