[New-bugs-announce] [issue40355] The ast module fails to reject certain malformed nodes

Brandt Bucher report at bugs.python.org
Tue Apr 21 15:59:22 EDT 2020


New submission from Brandt Bucher <brandtbucher at gmail.com>:

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.

----------
assignee: brandtbucher
components: Library (Lib)
messages: 366938
nosy: brandtbucher
priority: normal
severity: normal
status: open
title: The ast module fails to reject certain malformed nodes
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40355>
_______________________________________


More information about the New-bugs-announce mailing list