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 terry.reedy
Recipients docs@python, enedil, hniksic, iritkatriel, ncoghlan, pablogsal, terry.reedy
Date 2021-09-06.18:18:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1630952318.72.0.799528471339.issue30637@roundup.psfhosted.org>
In-reply-to
Content
The doc section in question is
https://docs.python.org/3/library/ast.html#ast.parse

I confirmed that 'break', 'continue', 'yield', and 'return' still parse, with the results how having "type_ignores=[]" added.
  'Module(body=[Expr(value=Yield())], type_ignores=[])'
I do not understand Nick's comment about 'await' as 'await' is not a legal statement'

The current initial paragraph says:
  "Parse the source into an AST node. Equivalent to compile(source, filename, mode, ast.PyCF_ONLY_AST)."

I suggest following this with:
  "If the AST node is compiled to a code object, there are additional syntax checks that can raise errors.  "For example, 'return' parses to a node, but is not legal outside of a def statement."

Hrvoje's suggested adding something like
  "If source contains a null character ('\0'), ValueError is raised."

I don't think that this is needed as ast.parse is explicitly noted as equivalent to a compile call, and the compile doc says "This function raises SyntaxError if the compiled source is invalid, and ValueError if the source contains null bytes."  (Should not that be 'null characters' given that *source* is now unicode?) This statement need not be repeated here.
History
Date User Action Args
2021-09-06 18:18:38terry.reedysetrecipients: + terry.reedy, ncoghlan, hniksic, docs@python, enedil, pablogsal, iritkatriel
2021-09-06 18:18:38terry.reedysetmessageid: <1630952318.72.0.799528471339.issue30637@roundup.psfhosted.org>
2021-09-06 18:18:38terry.reedylinkissue30637 messages
2021-09-06 18:18:38terry.reedycreate