diff --git a/CHANGES.md b/CHANGES.md index 48fe337392d..00c210ba86f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -39,6 +39,8 @@ - Fix bug with Black incorrectly parsing empty lines with a backslash (#4343) +- Fix bugs with Black's tokenizer not handling `\{` inside f-strings very well (#4422) + - Fix incorrect line numbers in the tokenizer for certain tokens within f-strings (#4423) diff --git a/src/blib2to3/pgen2/tokenize.py b/src/blib2to3/pgen2/tokenize.py index ecd017b3148..d15dc03d945 100644 --- a/src/blib2to3/pgen2/tokenize.py +++ b/src/blib2to3/pgen2/tokenize.py @@ -136,12 +136,12 @@ def _combinations(*l: str) -> Set[str]: ) # beginning of a single quoted f-string. must not end with `{{` or `\N{` -SingleLbrace = r"(?:\\N{|\\.|{{|[^'\\{])*(? Set[str]: _string_middle_double = r'(?:[^\n"\\]|\\.)*' # FSTRING_MIDDLE and LBRACE, must not end with a `{{` or `\N{` -_fstring_middle_single = r"(?:\\N{|\\[^{]|{{|[^\n'{\\])*(?