Skip to content

Commit a8c4d44

Browse files
Improve error message when given incorrect module path
1 parent a00655b commit a8c4d44

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lib/runpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _get_module_details(mod_name, error=ImportError):
135135
# pkgutil previously raised ImportError
136136
msg = "Error while finding module specification for {!r} ({}: {})"
137137
if mod_name.endswith(".py"):
138-
msg += (f". Try using '{mod_name[:-3]}' instead of "
138+
msg += (f". Try using '{mod_name[:-3].replace('/', '.')}' instead of "
139139
f"'{mod_name}' as the module name.")
140140
raise error(msg.format(mod_name, type(ex).__name__, ex)) from ex
141141
if spec is None:

0 commit comments

Comments
 (0)