[issue1875] "if 0: return" not raising SyntaxError

Benjamin Peterson report at bugs.python.org
Tue Feb 3 02:56:06 CET 2009


Benjamin Peterson <benjamin at python.org> added the comment:

You should remove the error logic compile.c for "return" and "yield" in
function calls.

The problem with this approach is that every SyntaxError generated
during bytecode compilation must be moved to earlier. For example, I can
still use "break" and "continue" outside loops with your patch. The only
way I can think of around this is to compile the block anyway and remove
the extra code later. Maybe this optimization could be moved to the peep
holer?

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1875>
_______________________________________


More information about the Python-bugs-list mailing list