Skip to content

Commit 600ede5

Browse files
committed
Prepend with a dot for better understanding
1 parent 726189c commit 600ede5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/traceback.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,11 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
11291129
wrong_name = getattr(exc_value, "name", None)
11301130
suggestion = _compute_suggestion_error(exc_value, exc_traceback, wrong_name)
11311131
if suggestion:
1132-
self._str += f". Did you mean '{suggestion}' instead of '{wrong_name}'?"
1132+
if issubclass(exc_type, AttributeError):
1133+
# Prepend with a dot for better understanding. See GH-144285.
1134+
self._str += f". Did you mean '.{suggestion}' instead of '.{wrong_name}'?"
1135+
else: # NameError
1136+
self._str += f". Did you mean '{suggestion}' instead of '{wrong_name}'?"
11331137
if issubclass(exc_type, NameError):
11341138
wrong_name = getattr(exc_value, "name", None)
11351139
if wrong_name is not None and wrong_name in sys.stdlib_module_names:

0 commit comments

Comments
 (0)