Skip to content

Formatting produces invalid code on 3.13.4 #18632

@MeGaGiGaGon

Description

@MeGaGiGaGon

Summary

With the release of 3.13.4, python/cpython#129958 was fixed, which now makes formatting produce invalid code on 3.13.4
playground link
Input:

f"{
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111:}"

Output:

f"{
    11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111:
}"

The input is valid code on 3.13.4, the output is not

$ uv run --python 3.13.4 python -c $'f"{\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111:}"'

$ uv run --python 3.13.4 python -c $'f"{\n    11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111:\n}"'
  File "<string>", line 2
    1111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111:

              ^
SyntaxError: f-string: newlines are not allowed in format specifiers for single
quoted f-strings

Version

No response

Metadata

Metadata

Assignees

Labels

formatterRelated to the formatterparserRelated to the parserpython313Related to Python 3.13python314Related to Python 3.14

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions