You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The ast module fails to reject certain malformed nodes #84535
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
Activity
brandtbucher commentedon Apr 21, 2020
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:
I'm currently working on a patch to raise errors instead.
isidentical commentedon Apr 21, 2020
See https://bugs.python.org/msg360767 for ast.unparse's point of view regarding malformed nodes.
pablogsal commentedon May 5, 2020
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
miss-islington commentedon May 5, 2020
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