Fix startup crash on Python 3.14 (pkgutil.find_loader removed)#411
Open
loki980 wants to merge 1 commit into
Open
Fix startup crash on Python 3.14 (pkgutil.find_loader removed)#411loki980 wants to merge 1 commit into
loki980 wants to merge 1 commit into
Conversation
Python 3.14 removed pkgutil.find_loader (deprecated since 3.12),
causing bauh to crash on launch with:
AttributeError: module 'pkgutil' has no attribute 'find_loader'
Replace the deprecated pkgutil API with the modern importlib API:
- pkgutil.find_loader(name) -> importlib.util.find_spec(name)
- loader.load_module() -> importlib.import_module(name)
importlib.import_module is the recommended replacement and avoids
the deprecated Loader.load_module() path entirely.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
bauh fails to launch on Python 3.14 with:
pkgutil.find_loaderwas deprecated in Python 3.12 and removed in Python 3.14. This breaks bauh on every distro that has moved to 3.14 (Arch, CachyOS, Fedora 41+, etc.), tracked in #402.Fix
Migrate
bauh/view/core/gems.pyfrom the removedpkgutilAPI to the modernimportlibAPI:pkgutil.find_loader(name)→importlib.util.find_spec(name)(existence check)loader.load_module()→importlib.import_module(name)(actual load)Using
importlib.import_moduleis preferable tospec.loader.load_module()becauseLoader.load_module()has itself been deprecated since Python 3.4 and is slated for eventual removal —import_moduleis the recommended path forward.Verified
Tested on CachyOS with Python 3.14.4: bauh launches cleanly past the gems-loading stage and the main window renders.
Note on #407
There's an existing PR (#407) addressing the same crash. This PR proposes a slightly cleaner alternative:
importlib.import_modulerather thanspec.loader.load_module()(avoids relying on a separately-deprecated API)loadertospecto match what it actually holds (aModuleSpec)Happy to defer to #407 if the maintainer prefers that version. The main goal is just to get bauh launching on 3.14 again.