Closed
Description
Bug report
Bug description:
>>> value = 123
>>> f"{value:.{'2'}f}" # '123.00'
>>> f"{value:.
{'2f'}}" # '123.00'
# but, shouldn't this one below also be valid?
>>> f"{value:.
... {'2'}f}" # invalid
>>> f"{value:
... {'.2f'}}" # '123.00'
I am checking the code of CPython's lexer and am confused why the lexer resets to normal mode when it encounters line break in format spec
Lines 1338 to 1348 in d7672e5
Go back to the original PR: #110271
Seems this case is not covered by the test cases
The case above could be recognized by tokenizer, so maybe pegen should be modified.
However, since it goes back to normal mode, some corner cases cannot be handled by tokenizer:
>>> value = 123
>>> f"{value:#{'x'}}" # '0x7b'
>>> f"{value:
... #{'x'}}" # breaks the tokenizer
CPython versions tested on:
3.13
Operating systems tested on:
macOS