C:\Users\alexw\coding\cpython>python -m test test_fstring
Running Release|x64 interpreter...
0:00:00 Run tests sequentially
0:00:00 [1/1] test_fstring
C:\Users\alexw\coding\cpython\Lib\test\test_fstring.py:775: SyntaxWarning: invalid escape sequence '\_'
exec('f"{F():¯\_(ツ)_/¯}"', {'F': CustomFormat})
== Tests result: SUCCESS ==
1 test OK.
Total duration: 14.5 sec
Tests result: SUCCESS
======================================================================
ERROR: test_fstring_backslash_before_double_bracket (test.test_fstring.TestCase.test_fstring_backslash_before_double_bracket) (case="f'\\{{\\}}'", expected_result='\\{\\}')
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alexw\coding\cpython\Lib\test\test_fstring.py", line 1041, in test_fstring_backslash_before_double_bracket
result = eval(case)
^^^^^^^^^^
File "<string>", line 1
f'\{{\}}'
^
SyntaxError: invalid escape sequence '\{'
======================================================================
ERROR: test_fstring_backslash_before_double_bracket (test.test_fstring.TestCase.test_fstring_backslash_before_double_bracket) (case="f'\\{{'", expected_result='\\{')
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alexw\coding\cpython\Lib\test\test_fstring.py", line 1041, in test_fstring_backslash_before_double_bracket
result = eval(case)
^^^^^^^^^^
File "<string>", line 1
f'\{{'
^
SyntaxError: invalid escape sequence '\{'
======================================================================
ERROR: test_fstring_backslash_before_double_bracket (test.test_fstring.TestCase.test_fstring_backslash_before_double_bracket) (case="f'\\{{{1+1}'", expected_result='\\{2')
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alexw\coding\cpython\Lib\test\test_fstring.py", line 1041, in test_fstring_backslash_before_double_bracket
result = eval(case)
^^^^^^^^^^
File "<string>", line 1
f'\{{{1+1}'
^
SyntaxError: invalid escape sequence '\{'
======================================================================
ERROR: test_fstring_backslash_before_double_bracket (test.test_fstring.TestCase.test_fstring_backslash_before_double_bracket) (case="f'\\}}{1+1}'", expected_result='\\}2')
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alexw\coding\cpython\Lib\test\test_fstring.py", line 1041, in test_fstring_backslash_before_double_bracket
result = eval(case)
^^^^^^^^^^
File "<string>", line 1
f'\}}{1+1}'
^
SyntaxError: invalid escape sequence '\}'
======================================================================
ERROR: test_fstring_backslash_before_double_bracket (test.test_fstring.TestCase.test_fstring_backslash_before_double_bracket) (case="f'{1+1}\\}}'", expected_result='2\\}')
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alexw\coding\cpython\Lib\test\test_fstring.py", line 1041, in test_fstring_backslash_before_double_bracket
result = eval(case)
^^^^^^^^^^
File "<string>", line 1
f'{1+1}\}}'
^
SyntaxError: invalid escape sequence '\}'
----------------------------------------------------------------------
Ran 80 tests in 14.399s
FAILED (errors=5)
test test_fstring failed
test_fstring failed (5 errors)
== Tests result: FAILURE ==
1 test failed:
test_fstring
Total duration: 14.6 sec
Tests result: FAILURE
Python 3.13.0a0 (heads/main:ab3823a97b, Jun 19 2023, 14:46:42) [MSC v.1932 64 bit (AMD64)] on win32
Bug report
Running
python -m test test_fstringonmainresults in severalSyntaxWarningsbeing emitted.If I just run
python -m test test_fstringlocally, I get this:C:\Users\alexw\coding\cpython>python -m test test_fstring Running Release|x64 interpreter... 0:00:00 Run tests sequentially 0:00:00 [1/1] test_fstring C:\Users\alexw\coding\cpython\Lib\test\test_fstring.py:775: SyntaxWarning: invalid escape sequence '\_' exec('f"{F():¯\_(ツ)_/¯}"', {'F': CustomFormat}) == Tests result: SUCCESS == 1 test OK. Total duration: 14.5 sec Tests result: SUCCESSIf I run
python -We -m test test_fstring -vv, I get a different selection of SyntaxWarnings:Your environment
Linked PRs