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 benjamin.peterson, r.david.murray, terry.reedy, vstinner, ztane
Date 2014-05-17.23:49:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1400370590.43.0.442500835593.issue21385@psf.upfronthosting.co.za>
In-reply-to
Content
Summary of this post: compile currently checks user input with assert; this is a bug that should be changed.

I re-read astlinenotest.py and realized that FunctionDef is included in '*' and not some omitted import. (The latter is common for code posted on python-list, if not here. This illustrates why PEP 8 deprecates 'import *'; import ast ... ast.FunctionDef would have been clear on first reading.) So I ran the module in installed 3.4 and repository debug 3.5 and got the assert with the latter.

"It seems to me that when the lnotab was created, no one even had in mind that there would be an actually useful AST module that would be used for code generation." I am pretty sure this is correct. I suspect that the assert in question was originally intended to test the logic of the internal syntax tree line number generation. But now it also tests user input, which I and may others think is a bad idea.

A solution between removing the assert (and the internal check) and converting it to, say, ValueError("decreasing line no in input ast"), and thereby stopping code that now normally and legitimately works, would be to skip the asserts when the compile input is an ast instead of code.
History
Date User Action Args
2014-05-17 23:49:50terry.reedysetrecipients: + terry.reedy, vstinner, benjamin.peterson, r.david.murray, ztane
2014-05-17 23:49:50terry.reedysetmessageid: <1400370590.43.0.442500835593.issue21385@psf.upfronthosting.co.za>
2014-05-17 23:49:50terry.reedylinkissue21385 messages
2014-05-17 23:49:49terry.reedycreate