BPO | [38131](https://bugs.python.org/issue38131) --- | :--- Nosy | @benjaminp, @ikamensh, @pablogsal, @isidentical PRs | python/cpython#17715 *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: ```python assignee = None closed_at = None created_at = labels = ['interpreter-core', '3.9'] title = "compile(mode='eval') uninformative error message" updated_at = user = 'https://github.com/ikamensh' ``` bugs.python.org fields: ```python activity = actor = 'BTaskaya' assignee = 'none' closed = False closed_date = None closer = None components = ['Interpreter Core'] creation = creator = 'Ilya Kamenshchikov' dependencies = [] files = [] hgrepos = [] issue_num = 38131 keywords = ['patch'] message_count = 3.0 messages = ['352090', '358905', '368351'] nosy_count = 4.0 nosy_names = ['benjamin.peterson', 'Ilya Kamenshchikov', 'pablogsal', 'BTaskaya'] pr_nums = ['17715'] priority = 'normal' resolution = None stage = 'patch review' status = 'open' superseder = None type = None url = 'https://bugs.python.org/issue38131' versions = ['Python 3.9'] ``` ### Linked PRs * gh-150912
Activity
ikamensh commentedon Sep 12, 2019
While trying to construct a valid ast node programmatically, I have tried following:
Unfortunately this gives unhelpful error message:
Turns out I need to make body of ast.Expression not a list, but a node:
expr = ast.Expression(body=tree) # works
Confusion also comes from naming the field "body", which takes value of a list for ast.Module and some others.
isidentical commentedon Dec 27, 2019
with PR 17715
isidentical commentedon May 7, 2020
I've updated PR 17715 in order to point out exact field that error happened. Also it now only shows type
gh-82312: Further improvement of error messages for generating AST no…