@@ -559,6 +559,23 @@ def f_with_binary_operator():
559559 result_lines = self .get_exception (f_with_binary_operator )
560560 self .assertEqual (result_lines , expected_error .splitlines ())
561561
562+ def test_caret_for_binary_operators_with_unicode (self ):
563+ def f_with_binary_operator ():
564+ áóí = 20
565+ return 10 + áóí / 0 + 30
566+
567+ lineno_f = f_with_binary_operator .__code__ .co_firstlineno
568+ expected_error = (
569+ 'Traceback (most recent call last):\n '
570+ f' File "{ __file__ } ", line { self .callable_line } , in get_exception\n '
571+ ' callable()\n '
572+ f' File "{ __file__ } ", line { lineno_f + 2 } , in f_with_binary_operator\n '
573+ ' return 10 + áóí / 0 + 30\n '
574+ ' ~~~~^~~\n '
575+ )
576+ result_lines = self .get_exception (f_with_binary_operator )
577+ self .assertEqual (result_lines , expected_error .splitlines ())
578+
562579 def test_caret_for_binary_operators_two_char (self ):
563580 def f_with_binary_operator ():
564581 divisor = 20
@@ -593,6 +610,23 @@ def f_with_subscript():
593610 result_lines = self .get_exception (f_with_subscript )
594611 self .assertEqual (result_lines , expected_error .splitlines ())
595612
613+ def test_caret_for_subscript_unicode (self ):
614+ def f_with_subscript ():
615+ some_dict = {'ó' : {'á' : {'í' : {'theta' : 1 }}}}
616+ return some_dict ['ó' ]['á' ]['í' ]['beta' ]
617+
618+ lineno_f = f_with_subscript .__code__ .co_firstlineno
619+ expected_error = (
620+ 'Traceback (most recent call last):\n '
621+ f' File "{ __file__ } ", line { self .callable_line } , in get_exception\n '
622+ ' callable()\n '
623+ f' File "{ __file__ } ", line { lineno_f + 2 } , in f_with_subscript\n '
624+ " return some_dict['ó']['á']['í']['beta']\n "
625+ ' ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^\n '
626+ )
627+ result_lines = self .get_exception (f_with_subscript )
628+ self .assertEqual (result_lines , expected_error .splitlines ())
629+
596630 def test_traceback_specialization_with_syntax_error (self ):
597631 bytecode = compile ("1 / 0 / 1 / 2\n " , TESTFN , "exec" )
598632
@@ -3356,7 +3390,7 @@ def func():
33563390
33573391 actual = self .get_suggestion (func )
33583392 self .assertNotIn ("blech" , actual )
3359-
3393+
33603394 def test_name_error_with_instance (self ):
33613395 class A :
33623396 def __init__ (self ):
0 commit comments