-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#1462] Remove Deprecated load_module() Function #2217
[#1462] Remove Deprecated load_module() Function #2217
Conversation
The previous attempt was almost correct - but we needed to ensure that the system was aware of the module in order to handle it correctly.
Add Slightly More Useful Comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with multiple plugins, none broke, LGTM.
Just to be sure... that selection of plugins definitely covered the ones that both provide and make use of a module themselves, right ? I'm struggling to find any other actual examples. The idea is that some plugins might (also) provide a library for use by other plugins. Was that case tested ? Although, tbh, if it's that rare, I'd want to check they worked as intended on the old loading code as well.... |
Description
importlib's
load_module()
function has been deprecated since Python 3.4, and has been toyed with being removed in the past. To replace it, the importlibexec_module()
function has been introduced as a more "modern" method of importing modules, such as plugins.This is not a drop-in replacement, however. Some work needs to be done to resolve issues with some plugins and imports, particularly more complicated plugins which use dataclasses, decorators, and other more advanced functions. Previous attempts (such as 816d041) tried to simply work around this, however were not granular enough to suffice.
This fixes a bug with the last attempt at fixing this issue by ensuring that
sys.modules
is aware of the imported module and can process it correctly in its namespace. Only once this is done does the program attempt to load the plugin. This also adds additional error checking and validation to ensure that a valid plugin is being sent to the program.This will remove one of the major blocking events for us to move to Python 3.12 or beyond.,
Type of Change
How Tested
Tested on a number of third party and bundled plugins, including:
Notes
The previous attempt was almost correct - but we needed to ensure that the system was aware of the module in order to handle it correctly. Additional testing of 3rd party plugins to ensure no plugins break with this is recommended.
Resolves #1462