Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 89dc552

Browse files
suzakuCarreau
authored andcommitted
Fix #13700, consistently use the original name in error message
1 parent f89bb70 commit 89dc552

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

IPython/utils/path.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,13 @@ def get_py_filename(name):
8383
"""
8484

8585
name = os.path.expanduser(name)
86-
if not os.path.isfile(name) and not name.endswith('.py'):
87-
name += '.py'
8886
if os.path.isfile(name):
8987
return name
90-
else:
91-
raise IOError('File `%r` not found.' % name)
88+
if not name.endswith('.py'):
89+
py_name = name + '.py'
90+
if os.path.isfile(py_name):
91+
return py_name
92+
raise IOError('File `%r` not found.' % name)
9293

9394

9495
def filefind(filename: str, path_dirs=None) -> str:

0 commit comments

Comments
 (0)