Skip to content

Commit c973a52

Browse files
committed
Handle non-ASCII cases correctly
1 parent f80d3da commit c973a52

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Lib/test/test_traceback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4264,7 +4264,7 @@ class B:
42644264
attr_µ = None # attr_\xb5
42654265

42664266
suggestion = self.get_suggestion(B(), 'attr_\xb5')
4267-
self.assertIn("'attr_\u03bc'", suggestion)
4267+
self.assertIn("'.attr_\u03bc'", suggestion)
42684268
self.assertIn(r"'attr_\u03bc'", suggestion)
42694269
self.assertNotIn("attr_a", suggestion)
42704270

Lib/traceback.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,7 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
11371137
# See GH-144285.
11381138
self._str += f". Did you mean '.{suggestion}' instead of '.{wrong_name}'?"
11391139
else:
1140-
self._str += f". Did you mean: '{suggestion}' ({suggestion!a})?"
1140+
self._str += f". Did you mean: '.{suggestion}' ({suggestion!a}) instead of '.{wrong_name}' ({wrong_name!a})?"
11411141
elif exc_type and issubclass(exc_type, NameError) and \
11421142
getattr(exc_value, "name", None) is not None:
11431143
wrong_name = getattr(exc_value, "name", None)

0 commit comments

Comments
 (0)