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

f'"{var:}"' adds redundant empty string literal in AST in 3.12 #106396

Closed
Assignees
pablogsallysnikolaou
Labels
3.12only security fixes3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@sobolevn

Description

@sobolevn

3.11:

>>>importast>>>print(ast.dump(ast.parse("""f'"{var:}"'"""),indent=2))Module(body=[Expr(value=JoinedStr(values=[Constant(value='"'),FormattedValue(value=Name(id='var',ctx=Load()),conversion=-1,format_spec=JoinedStr(values=[])),Constant(value='"')]))],type_ignores=[])

3.12:

>>>importast>>>print(ast.dump(ast.parse("""f'"{var:}"'"""),indent=2))Module(body=[Expr(value=JoinedStr(values=[Constant(value='"'),FormattedValue(value=Name(id='var',ctx=Load()),conversion=-1,format_spec=JoinedStr(values=[Constant(value='')])),Constant(value='"')]))],type_ignores=[])

This affects several linters:

  1. Fix parse test case on Python 3.12 mypy#15577
  2. B907 crashes when bugbear is run on Python 3.12 PyCQA/flake8-bugbear#393

Is this a bug? Or is it a feature?

Linked PRs

Metadata

Metadata

Labels

3.12only security fixes3.13bugs 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