This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients methane, vstinner
Date 2017-02-22.16:48:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487782112.74.0.332451655516.issue29622@psf.upfronthosting.co.za>
In-reply-to
Content
The _ast.AST constructor requires a tuple with the same number of items than the fields list.

Example with Raise:

ASDL: Raise(expr? exc, expr? cause)

>>> import _ast
>>> _ast.Raise()
<_ast.Raise object at 0x7fc2ca7dee90>
>>> _ast.Raise(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Raise constructor takes either 0 or 2 positional arguments
>>> _ast.Raise(1, 2)
<_ast.Raise object at 0x7fc2ca7def60>

The cause field is optional in the ASDL, but required in the _ast module.

A tradeoff would be to add the minimum and maximum number of fields to _ast.AST.

This issue should prevent API breakage caused by the new docstring attribute added by issue #29463.
History
Date User Action Args
2017-02-22 16:48:32vstinnersetrecipients: + vstinner, methane
2017-02-22 16:48:32vstinnersetmessageid: <1487782112.74.0.332451655516.issue29622@psf.upfronthosting.co.za>
2017-02-22 16:48:32vstinnerlinkissue29622 messages
2017-02-22 16:48:32vstinnercreate