Skip to content

Commit 7f4b748

Browse files
Update traceback.py
1 parent 57a3aca commit 7f4b748

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/traceback.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,8 @@ def _compute_suggestion_error(exc_value, tb, wrong_name):
16421642
if wrong_name[:1] != '_':
16431643
d = [x for x in d if x[:1] != '_']
16441644
except Exception:
1645+
if not isinstance(exc_value, ModuleNotFoundError):
1646+
return None
16451647
scan_dir, find_all_packages = _find_all_packages()
16461648
import os
16471649
list_d = find_all_packages()
@@ -1650,7 +1652,7 @@ def _compute_suggestion_error(exc_value, tb, wrong_name):
16501652
module_name = wrong_name_list[0]
16511653
if module_name not in sys.modules:
16521654
wrong_name = module_name
1653-
exc_value.msg = f"no module named '{module_name}'"
1655+
exc_value.msg = f"No module named '{module_name}'"
16541656
if len(wrong_name_list) == 1:
16551657
if (_closed_name := _calculate_closed_name(module_name, sorted(sys.stdlib_module_names))):
16561658
return _closed_name # stdlib first

0 commit comments

Comments
 (0)