hy/tests/native_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
..
contrib fixed ap-map potential naming conflict 2014-04-18 02:45:05 +02:00
__init__.hy ideas, ideas. 2013-03-05 18:39:34 -05:00
cons.hy Add a cons object and related mechanisms 2014-01-23 23:08:52 +01:00
core.hy Merge branch 'master' into pr/571 2014-05-13 09:32:51 +03:00
defclass.hy Fix missing docstrings from defclass issue #248 2013-07-15 06:58:08 -06:00
language.hy Second part of the fix for yield inside a try-finally 2014-06-22 14:59:29 -06:00
math.hy Operators + and * work without args, fixes #372 2013-12-16 00:04:43 +05:30
native_macros.hy Merge branch 'master' into pr/515 2014-04-10 22:52:41 -04:00
quote.hy Remove HyLambdaListKeyword from the parser 2014-06-03 21:36:49 -04:00
reader_macros.hy Fix reader macros to actually be macros 2014-01-17 01:07:47 +01:00
unless.hy add nil as synonym for None 2013-12-27 13:50:19 -07:00
when.hy add nil as synonym for None 2013-12-27 13:50:19 -07:00
with_decorator.hy Rename decorate-with' to with-decorator' 2013-04-28 17:14:22 +02:00
with_test.hy added for and with macros 2013-12-29 16:50:21 +01:00