[Debian-zh-dev] Bug#1134570: galternatives fails to run with "__annotations__ is not defined" errors

Thomas Ward teward at ubuntu.com
Tue Apr 21 22:01:06 BST 2026


Package: galternatives
Version: 1.0.10
Severity: normal
Tags: experimental

Note that in Unstable, we use Python 3.13. However, if you install 
Python 3.14 and use that as your system defaults (NOT advised), you will 
replicate this error.

This issue was originally discovered because downstream in Ubuntu for 
Ubuntu 26.04 development cycle, we use Python 3.14 down there. Thus 
showing the Python 3.14 issues here.

---

When trying to run `galternatives` in a Python 3.14 environment, we are 
met with the following crash and failure to execute the software:

Traceback (most recent call last):
   File "/usr/bin/galternatives", line 6, in <module>
     runpy.run_module('galternatives', run_name='__main__')
     ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "<frozen runpy>", line 229, in run_module
   File "<frozen runpy>", line 88, in _run_code
   File "/usr/lib/python3/dist-packages/galternatives/__main__.py", line 
12, in <module>
     from galternatives.app import GAlternativesApp
   File "/usr/lib/python3/dist-packages/galternatives/app.py", line 19, 
in <module>
     from .alternative import AltDB, AltGroup, AltOption, CommandResult
   File "/usr/lib/python3/dist-packages/galternatives/alternative.py", 
line 55, in <module>
     class AltOption(dict[str, str]):
     ...<71 lines>...
                 for i in range(len(group)))
   File "/usr/lib/python3/dist-packages/galternatives/alternative.py", 
line 65, in AltOption
     __slots__ = tuple(__annotations__)
                       ^^^^^^^^^^^^^^^
NameError: name '__annotations__' is not defined

---

Upon examination of Python Best Practices [1], it is suggested that 
`annotationlib.get_annotations()` be used wherever a direct 
`__annotations__` reference is made.

However, this cannot be done bare, it has to refer to the object itself. 
Additionally, __annotations__ isn't defined by default for classes 
anymore, and thus attempting to set `__slots__` before instantiation 
with `__init__` does not work.

Downstream, and after an hour of poking, changes to set `__slots__` 
during initialization made it capable to fix this issue.

A patch via Merge Request has been made available on Salsa, without 
d/changelog entries. [2]


Thomas


[1]: https://docs.python.org/3/howto/annotations.html

[2]: https://salsa.debian.org/chinese-team/galternatives/-/merge_requests/1



More information about the Chinese-developers mailing list