Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tokenize does not roundtrip {{ after \n #125008

Closed
Assignees
pablogsallysnikolaou
Labels
3.12only security fixes3.13bugs and security fixes3.14bugs and security fixestopic-parsertype-bugAn unexpected behavior, bug, or error
@wyattscarpenter

Description

@wyattscarpenter

Bug report

Bug description:

importtokenize,iosource_code=r'''f"""{80 * '*'}\n{{test}}{{details}}{{test2}}\n{80 * '*'}"""'''tokens=tokenize.generate_tokens(io.StringIO(source_code).readline)x=tokenize.untokenize((t,s)fort,s,*_intokens)print(x)

Expected:

f"""{80 *'*'}\n{{test}}{{details}}{{test2}}\n{80 *'*'}"""

Got:

f"""{80 *'*'}\n{test}}{{details}}{{test2}}\n{80 *'*'}"""

Note the absence of a second { in the {{ after the \n — but in no other positions.

Unlike some other roundtrip failures of tokenize, some of which are minor infelicities, this one actually creates a syntactically invalid program on roundtrip, which is quite bad. You get aSyntaxError: f-string: single '}' is not allowed when trying to use the results.

CPython versions tested on:

3.12

Operating systems tested on:

Linux, Windows

Linked PRs

Metadata

Metadata

Labels

3.12only security fixes3.13bugs and security fixes3.14bugs and security fixestopic-parsertype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp