hy/tests
Bob Tolbert ea5eba5916 Second part of the fix for yield inside a try-finally
As noted in #600, Python 3 allows a return inside a generator
method, that raises a StopIteration and passes the return value
inside the 'value' attr of the exception.

To allow this behaviour we simple set 'contains_yield' while compiling
'yield', thus allowing a return statement, but only for Python 3. Then
when compiling the try-except, we check for contains_yield to decide
whether there will be a return.

This allows code like:

(defn gen []
  (yield 3)
  "goodbye")

to compile in both Py2 and Py3. The return value is simply ignored in
Python 2.

hy2py in Python 2 gives:

def g():
    yield 3L
    u'goodbye'

while hy2py in Python 3 gives:

def g():
    yield 3
    return 'goodbye'

Turns out return in yield started in Python 3.3
2014-06-22 14:59:29 -06:00
..
compilers Kill kwapply. 2014-04-09 20:10:31 +03:00
importer hy/compiler.py: import only handles HySymbol and HyList, bail on others 2014-02-11 17:29:50 +01:00
lex Remove HyLambdaListKeyword from the parser 2014-06-03 21:36:49 -04:00
macros Hy reader macros #377 2013-12-23 14:33:51 +01:00
models Merge master onto pr/471 2014-01-30 21:50:23 +05:30
native_tests Second part of the fix for yield inside a try-finally 2014-06-22 14:59:29 -06:00
resources defmain macro; handles the whole if __name__ == __main__ / main function dance 2014-04-10 13:58:38 -05:00
__init__.py Add Curry module. 2014-03-29 14:40:13 -04:00
test_bin.py Merge branch 'master' into pr/526 2014-05-02 10:34:37 +03:00