Amaury Forgeot d'Arc <amaur...@gmail.com> added the comment:

Here is a patch that properly raises SyntaxError when 'return' or  
'yield' statements appear outside a function.

I did not bother to update the (deprecated) compiler package: it seems 
to be completely foreign to this kind of checks...

>>> dis.dis(compiler.compile("return 1", "module.py", "exec"))
  1           0 LOAD_CONST               1 (1)
              3 RETURN_VALUE
              4 LOAD_CONST               0 (None)
              7 RETURN_VALUE

----------
assignee:  -> amaury.forgeotdarc
keywords: +needs review, patch
resolution: fixed -> 
status: closed -> open
Added file: http://bugs.python.org/file12926/return_outside_func.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1875>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to