injector: Python 3.10 regression: injector.UnknownProvider: couldn't determine provider
Some users of Fedora 35 reported that an app I developed doesn’t work anymore after upgrading from Fedora 43.
After some investigation it seems related to the upgrade to Python 3.10. I was able to reproduce the same issue on Ubuntu 21.10 after installing Python 3.10 and running the app on a venv that uses it.
This is the relevant traceback:
Traceback (most recent call last):
File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 658, in get_binding
return self._get_binding(interface, only_this_binder=is_scope)
File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 653, in _get_binding
raise KeyError
KeyError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/leinardi/Workspace/gitlab/gwe/.pycharm/gwe", line 43, in <module>
from gwe import __main__
File "/home/leinardi/Workspace/gitlab/gwe/gwe/__main__.py", line 33, in <module>
from gwe.model.current_fan_profile import CurrentFanProfile
File "/home/leinardi/Workspace/gitlab/gwe/gwe/model/__init__.py", line 19, in <module>
from gwe.model.overclock_profile import OverclockProfile
File "/home/leinardi/Workspace/gitlab/gwe/gwe/model/overclock_profile.py", line 29, in <module>
OVERCLOCK_PROFILE_CHANGED_SUBJECT = INJECTOR.get(OverclockProfileChangedSubject)
File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 952, in get
binding, binder = self.binder.get_binding(interface)
File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 667, in get_binding
binding = self.create_binding(interface)
File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 582, in create_binding
provider = self.provider_for(interface, to)
File "/home/leinardi/Workspace/gitlab/gwe/venv/lib/python3.10/site-packages/injector/__init__.py", line 644, in provider_for
raise UnknownProvider('couldn\'t determine provider for %r to %r' % (interface, to))
injector.UnknownProvider: couldn't determine provider for gwe.di.OverclockProfileChangedSubject to None
The code that is triggering the issue is this one:
OVERCLOCK_PROFILE_CHANGED_SUBJECT = INJECTOR.get(OverclockProfileChangedSubject)
where OverclockProfileChangedSubject
is defined as:
OverclockProfileChangedSubject = NewType('OverclockProfileChangedSubject', Subject)
This code worked fine for several versions of Python and version 3.10 seems to be the only one affected.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 18
- Comments: 17
@jstasiak any suggestion?
This is now also an issue on Arch Linux, as it’s been moved to 3.10 as well. It’s going to be an issue everywhere eventually.
No worries. It’s just been released as version 0.19.0, enjoy.
@jstasiak please have a look at #193
It’s no longer needed, after I reported the issue, the maintainer updated the PKGBUILD so all is good now. No editing of PKGBUILDs necessary. So anyone not able to wait can just use
python-injector-git
from the AUR (if they’re on an Arch-based distro). Beyond that, I’d say this is probably venturing into off-topic territory from here on out@leinardi I will say that I installed
python-injector-git
from the AUR (I had to edit the PKGBUILD because the writer of it has it in a broken state but it was a quick fix) and after installing that, GWE works perfectly.@jstasiak Thank you for merging the fix 👍
Is there an ETA for the next release that will include this fix?