Skip to content

ImportFinder: Support find_spec interface #836

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

Merged
merged 1 commit into from
Jul 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions bpython/curtsiesfrontend/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,18 @@ def find_distributions(self, context):

return None

def find_spec(self, fullname, path, target=None):
for finder in self.old_meta_path:
# Consider the finder only if it implements find_spec
if not getattr(finder, "find_spec", None):
continue
# Attempt to find the spec
spec = finder.find_spec(fullname, path, target)
if spec is not None:
# Patch the loader to enable reloading
spec.__loader__ = ImportLoader(self.watcher, spec.__loader__)
return spec

def find_module(self, fullname, path=None):
for finder in self.old_meta_path:
loader = finder.find_module(fullname, path)
Expand Down