Skip to content

Commit

Permalink
fixup! pythongh-115154: Fix untokenize handling of unicode named lite…
Browse files Browse the repository at this point in the history
…rals
  • Loading branch information
pablogsal committed Feb 11, 2024
1 parent 3ce1233 commit d212f92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Lib/tokenize.py
Expand Up @@ -215,8 +215,9 @@ def untokenize(self, iterable):
elif tok_type == FSTRING_MIDDLE:
if '{' in token or '}' in token:
end_line, end_col = end
token = re.sub(r'(?<!\\N){([^{}]*)}', r'{{\1}}', token)
end = (end_line, end_col + token.count('{') + token.count('}') - 2)
end = (end_line, end_col + token.count('{') + token.count('}'))
token = re.sub('{', '{{', token)
token = re.sub('}', '}}', token)


self.add_whitespace(start)
Expand Down Expand Up @@ -263,7 +264,8 @@ def compat(self, token, iterable):
startline = False
elif toknum == FSTRING_MIDDLE:
if '{' in tokval or '}' in tokval:
tokval = re.sub(r'(?<!\\N){([^{}]*)}', r'{{\1}}', tokval)
tokval = re.sub('{', '{{', tokval)
tokval = re.sub('}', '}}', tokval)

toks_append(tokval)

Expand Down
1 change: 1 addition & 0 deletions lol.py
@@ -0,0 +1 @@
compile('match y:\n case e(e=v,v,', '<na>', 'exec')

0 comments on commit d212f92

Please sign in to comment.