Skip to content

Commit 105d551

Browse files
Commit
1 parent b4d2307 commit 105d551

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Lib/traceback.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,11 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
11101110
elif exc_type and issubclass(exc_type, ModuleNotFoundError):
11111111
module_name = getattr(exc_value, "name", None)
11121112
if module_name in sys.stdlib_module_names:
1113-
self._str = f"Standard library module '{module_name}' was not found"
1113+
message = _missing_stdlib_module.get(
1114+
module_name,
1115+
f"Standard library module '{module_name}' was not found"
1116+
)
1117+
self._str = message
11141118
elif sys.flags.no_site:
11151119
self._str += (". Site initialization is disabled, did you forget to "
11161120
+ "add the site-packages directory to sys.path "
@@ -1794,3 +1798,11 @@ def _levenshtein_distance(a, b, max_cost):
17941798
# Everything in this row is too big, so bail early.
17951799
return max_cost + 1
17961800
return result
1801+
1802+
_windows_only_modules = ["winreg", "msvcrt", "winsound", "nt", "_winapi", "_msi"]
1803+
1804+
_missing_stdlib_module = {
1805+
name: f"Windows-only standard library module '{name}' not found"
1806+
for name in _windows_only_modules
1807+
# Distributors can patch this dictionary to provide installation suggestions.
1808+
}

0 commit comments

Comments
 (0)