Skip to content

Commit afc28c3

Browse files
committed
Do not patch __loader__ if not available
1 parent 84d581a commit afc28c3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,14 @@ def find_distributions(self, context):
290290
def find_spec(self, fullname, path, target=None):
291291
for finder in self.old_meta_path:
292292
# Consider the finder only if it implements find_spec
293-
if not getattr(finder, "find_spec", None):
293+
if getattr(finder, "find_spec", None) is None:
294294
continue
295295
# Attempt to find the spec
296296
spec = finder.find_spec(fullname, path, target)
297297
if spec is not None:
298-
# Patch the loader to enable reloading
299-
spec.__loader__ = ImportLoader(self.watcher, spec.__loader__)
298+
if getattr(spec, "__loader__", None) is not None:
299+
# Patch the loader to enable reloading
300+
spec.__loader__ = ImportLoader(self.watcher, spec.__loader__)
300301
return spec
301302

302303
def find_module(self, fullname, path=None):

0 commit comments

Comments
 (0)