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 enedil
Recipients enedil, hniksic
Date 2017-06-13.11:53:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1497354792.93.0.568113770717.issue30637@psf.upfronthosting.co.za>
In-reply-to
Content
Docs mention:


ast.parse(source, filename='<unknown>', mode='exec')
    Parse the source into an AST node. Equivalent to compile(source, filename, mode, ast.PyCF_ONLY_AST).

If you just parse code into AST, you first check whether it is possible to turn such source into a Python syntax tree. In that case, it obviously is, as you may imagine a function, that returns nothing:

def func():
    return

If however you try to make executable code of the source, it is checked whether the constructs make sense in provided context. And, as you may imagine, top-level code with return statement is not valid, hence the error.
History
Date User Action Args
2017-06-13 11:53:12enedilsetrecipients: + enedil, hniksic
2017-06-13 11:53:12enedilsetmessageid: <1497354792.93.0.568113770717.issue30637@psf.upfronthosting.co.za>
2017-06-13 11:53:12enedillinkissue30637 messages
2017-06-13 11:53:12enedilcreate