Skip to content

Commit a453c02

Browse files
committed
ImportFinder: Support find_spec interface
1 parent ac93c74 commit a453c02

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,18 @@ def find_distributions(self, context):
287287

288288
return None
289289

290+
def find_spec(self, fullname, path, target=None):
291+
for finder in self.old_meta_path:
292+
# Consider the finder only if it implements find_spec
293+
if not getattr(finder, "find_spec", None):
294+
continue
295+
# Attempt to find the spec
296+
spec = finder.find_spec(fullname, path, target)
297+
if spec is not None:
298+
# Patch the loader to enable reloading
299+
spec.__loader__ = ImportLoader(self.watcher, spec.__loader__)
300+
return spec
301+
290302
def find_module(self, fullname, path=None):
291303
for finder in self.old_meta_path:
292304
loader = finder.find_module(fullname, path)

0 commit comments

Comments
 (0)