There are several places in the ast module where the use of zip is allowing malformed nodes to have unpaired children silently thrown away. A couple of short examples:
>>> from ast import Constant, Dict, literal_eval, unparse
>>> nasty_dict = Dict(keys=[Constant("I don't have a value!")], values=[])
>>> unparse(nasty_dict)
'{}'
>>> literal_eval(nasty_dict)
{}
I'm currently working on a patch to raise errors instead.
New changeset c21c512 by Curtis Bucher in branch 'master': bpo-40355: Improve error messages in ast.literal_eval with malformed Dict nodes (GH-19868) c21c512
New changeset 2a3b876 by Miss Islington (bot) in branch '3.8': bpo-40355: Improve error messages in ast.literal_eval with malformed Dict nodes (GH-19868) 2a3b876
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: