File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 12
12
import dis
13
13
import os
14
14
import re
15
+ import tokenize
15
16
import types
16
17
import decimal
17
18
import unittest
18
19
import warnings
20
+ from io import BytesIO
19
21
from test import support
20
22
from test .support .os_helper import temp_cwd
21
23
from test .support .script_helper import assert_python_failure , assert_python_ok
@@ -1859,6 +1861,12 @@ def __format__(self, format):
1859
1861
# Test multiple format specs in same raw f-string
1860
1862
self .assertEqual (rf"{ UnchangedFormat ():\xFF} { UnchangedFormat ():\n} " , '\\ xFF \\ n' )
1861
1863
1864
+ def test_gh139516 (self ):
1865
+ # gh-139516
1866
+ # The '\n' is explicit to ensure no trailing whitespace which would invalidate the test.
1867
+ # Must use tokenize instead of compile so that source is parsed by line which exposes the bug.
1868
+ list (tokenize .tokenize (BytesIO ('''f"{f(a=lambda: 'à'\n )}"''' .encode ()).readline ))
1869
+
1862
1870
1863
1871
if __name__ == '__main__' :
1864
1872
unittest .main ()
You can’t perform that action at this time.
0 commit comments