8000 ast.unparse: Wrong unparse with something like "() = []". · Issue #92671 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
ast.unparse: Wrong unparse with something like "() = []". #92671
Closed
@NIKDISSV-Forever

Description

@NIKDISSV-Forever

Generates incorrect code if unparse passes an assignment with an empty tuple on the left side.

import ast
ast.unparse(ast.parse("() = []")) # " = []"
ast.unparse(ast.parse("[] = () = []")) # "[] = = []"

The simplest solution would be to remove the line
self.set_precedence(_Precedence.TUPLE, target)
in ast._Unparser.visit_Assign

Doesn't work properly in 3.11.0b1, 3.12.0a0
In 3.9.12, 3.10.4 - works correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixestype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0