Nick Coghlan added the comment: codeop compiles the whole pending statement every time, so that part shouldn't be needed (from the compiler's point of view, this input looks complete - there's nothing dangling, any more than there is for a normal syntax error like "name name"). As far as I can tell, the only reason it works in the internal parser case is because the parser doesn't consider the input complete until it sees the expected dedents, which the tokenizer doesn't generate until it sees the trailing newline.
That may actually be another alternative: instead of doing the "try appending newlines and see if it works or generates different errors", we may be able to switch to the tokenizer if the initial compilation fails and check for hanging INDENT tokens (i.e. INDENTS without a corresponding DEDENT). That would get us much closer to what the real eval loop is doing. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19335> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com