mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Remove more usage of APIs deprecated by PEP 451.
This commit is contained in:
parent
3a62d14b24
commit
02b9f9d6bb
3 changed files with 16 additions and 14 deletions
|
@ -659,20 +659,20 @@ class EditorWindow(object):
|
|||
return
|
||||
# XXX Ought to insert current file's directory in front of path
|
||||
try:
|
||||
loader = importlib.find_loader(name)
|
||||
spec = importlib.find_spec(name)
|
||||
except (ValueError, ImportError) as msg:
|
||||
tkMessageBox.showerror("Import error", str(msg), parent=self.text)
|
||||
return
|
||||
if loader is None:
|
||||
if spec is None:
|
||||
tkMessageBox.showerror("Import error", "module not found",
|
||||
parent=self.text)
|
||||
return
|
||||
if not isinstance(loader, importlib.abc.SourceLoader):
|
||||
if not isinstance(spec.loader, importlib.abc.SourceLoader):
|
||||
tkMessageBox.showerror("Import error", "not a source-based module",
|
||||
parent=self.text)
|
||||
return
|
||||
try:
|
||||
file_path = loader.get_filename(name)
|
||||
file_path = spec.loader.get_filename(name)
|
||||
except AttributeError:
|
||||
tkMessageBox.showerror("Import error",
|
||||
"loader does not support get_filename",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue