-
Notifications
You must be signed in to change notification settings - Fork 192
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
👌 IMPROVE: Replace deprecated imp with importlib #4848
Changes from 1 commit
daf0ae7
cc3fe75
bd34362
7e49cf0
6f65535
520311a
798775d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,8 @@ | |
########################################################################### | ||
"""Translator for node""" | ||
import pkgutil | ||
import imp | ||
import importlib | ||
import sys | ||
import inspect | ||
import os | ||
|
||
|
@@ -346,12 +347,15 @@ def _get_subclasses(self, parent=None, parent_class=None, recursive=True): | |
full_path_base = os.path.join(package_path, name) | ||
|
||
if is_pkg: | ||
app_module = imp.load_package(full_path_base, full_path_base) | ||
spec = importlib.util.spec_from_file_location(name, full_path_base) | ||
app_module = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(app_module) | ||
else: | ||
full_path = f'{full_path_base}.py' | ||
# I could use load_module but it takes lots of arguments, | ||
# then I use load_source | ||
app_module = imp.load_source(f'rst{name}', full_path) | ||
spec = importlib.util.spec_from_file_location(f'rst{name}', full_path) | ||
app_module = importlib.util.module_from_spec(spec) | ||
sys.modules[f'rst{name}'] = app_module | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here (or perhaps I don't understand what this does). is this some weird autocomplete of "firstname" in the editor? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and I have changed them accordingly |
||
spec.loader.exec_module(app_module) | ||
|
||
# Go through the content of the module | ||
if not is_pkg: | ||
|
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.
typo?