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

untokenize() round-trip fails for t-strings (with only type + string) #134582

Open
Labels
3.14bugs and security fixes3.15new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@loic-simon

Description

@loic-simon

Bug report

Bug description:

Found when investigatingtest.test_tokenize.TestRoundtrip.test_random_files failing on#134577

deftest(code):tokens=list(tokenize.tokenize(iter([code]).__next__))from5=tokenize.untokenize(tokens)print("from5   ",from5,eval(from5))tokens2= [tok[:2]fortokintokens]from2=tokenize.untokenize(tokens2)print("from2   ",from2,eval(from2))
>>> test(b't"{ {} }"')from5    b't"{ {} }"' Template(strings=('', ''), interpolations=(Interpolation({}, ' {}', None, ''),))from2    b't"{{}}"'   Template(strings=('{}',), interpolations=())>>> test(b'f"{ {} }"')from5    b'f"{ {} }"' {}from2    b'f"{ {} }"' {}

From what I understand,untokenize should round-trip correctly even with only the type and string of tokens.

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-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