we-like-parsers / cpython

Here we work on integrating pegen into CPython; use branch 'pegen'
https://github.com/gvanrossum/pegen
Other
1 stars 0 forks source link

f-string parser: Fix "'unicodeescape' codec can't decode bytes in position 0-2: malformed \N character escape" #154

Closed pablogsal closed 3 years ago

pablogsal commented 3 years ago

In test_fstring, the test test_misformed_unicode_character_name is failing with:

ERROR: test_misformed_unicode_character_name (test.test_fstring.TestCase) (str="'\N{'")\n---------------------------------------------------------------------- Traceback (most recent call last): File "/home/pablogsal/github/python/f-string-grammar/Lib/test/test_fstring.py", line 33, in assertAllRaise eval(str) ^^^^^^^^^ UnicodeDecodeError: 'unicodeescape' codec can't decode bytes in position 0-2: malformed \N character escape

isidentical commented 3 years ago

Seems like unicode escapes doesn't work at all

(.venv) (3.9.5) [ 12:25ÖÖ ]  [ isidentical@msi:~/projects/cpython(test-fixes✅) ]
 $ ./python                                                                              3ms
Python 3.11.0a0 (heads/fstring-grammar-dirty:81ed1ec640, Oct 26 2021, 00:23:59) [GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f"\N{BULLET}"
'\\N{BULLET}'
>>> 
(.venv) (3.9.5) [ 12:26ÖÖ ]  [ isidentical@msi:~/projects/cpython(test-fixes✅) ]
 $ python                                                                             6,978s
Python 3.9.5 (default, May 11 2021, 08:20:37) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f"\N{BULLET}"
'•'
>>>