Skip to content

Commit d0f68a0

Browse files
committed
Don't prepend with dots in non-ASCII case
This is extremely unlikely Keeping parity with this case would just be unhelpful
1 parent 03b1f45 commit d0f68a0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/traceback.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,9 +1133,12 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
11331133
suggestion = _compute_suggestion_error(exc_value, exc_traceback, wrong_name)
11341134
if suggestion:
11351135
if suggestion.isascii():
1136+
# Prepending attribute accesseses with a dot makes the message much
1137+
# easier to understand in the most common cases.
1138+
# See GH-144285.
11361139
self._str += f". Did you mean '.{suggestion}' instead of '.{wrong_name}'?"
11371140
else:
1138-
self._str += f". Did you mean '.{suggestion}' ({suggestion!a}) instead of '.{wrong_name}'?"
1141+
self._str += f". Did you mean: '{suggestion}' ({suggestion!a})?"
11391142
elif exc_type and issubclass(exc_type, NameError) and \
11401143
getattr(exc_value, "name", None) is not None:
11411144
wrong_name = getattr(exc_value, "name", None)

0 commit comments

Comments
 (0)