MNT: do not use deprecated load_module method#218
Merged
uglide merged 2 commits intoredis:masterfrom Jan 30, 2026
Merged
Conversation
The load_module method has been deprecated from py34 and will be removed in py315 [1] (it is already gone on CPython main). The recommended replacement is exec_module, however the documentation [2] suggests to use a simpler approach than using the loaders directly and runpy [3] seemed better than sys.path hacking. Given that this is a one-line file simply reading the file and parsing it 'by hand' is an option. [1] https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.load_module [2] https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly [3] https://docs.python.org/3/library/runpy.html#runpy.run_path
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
There was a problem hiding this comment.
Pull request overview
Updates packaging/version retrieval to avoid importlib’s deprecated Loader.load_module() (removed on CPython main and slated for removal in Python 3.15), switching to a supported mechanism.
Changes:
- Replace
importlib.machinery.SourceFileLoader(...).load_module()usage insetup.pywithrunpy.run_path(...). - Remove the
importlibimport and addrunpy.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
uglide
approved these changes
Jan 30, 2026
Contributor
uglide
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
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.
The load_module method has been deprecated from py34 and will be removed in py315 [1] (it is already gone on CPython main).
The recommended replacement is exec_module, however the documentation [2] suggests to use a simpler approach than using the loaders directly and runpy [3] seemed better than sys.path hacking.
Given that this is a one-line file simply reading the file and parsing it 'by hand' is an option.
[1] https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.load_module
[2] https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
[3] https://docs.python.org/3/library/runpy.html#runpy.run_path