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 amaury.forgeotdarc
Recipients Carl.Friedrich.Bolz, amaury.forgeotdarc, arigo, benjamin.peterson, fijal, mark.dickinson
Date 2009-02-02.23:48:23
SpamBayes Score 3.52479e-05
Marked as misclassified No
Message-id <>
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", "", "exec"))
  1           0 LOAD_CONST               1 (1)
              3 RETURN_VALUE
              4 LOAD_CONST               0 (None)
              7 RETURN_VALUE
Date User Action Args
2009-02-02 23:48:27amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, arigo, mark.dickinson, fijal, Carl.Friedrich.Bolz, benjamin.peterson
2009-02-02 23:48:27amaury.forgeotdarcsetmessageid: <>
2009-02-02 23:48:25amaury.forgeotdarclinkissue1875 messages
2009-02-02 23:48:24amaury.forgeotdarccreate