Merge branch 'kirbyfan64-yield-ret'

This commit is contained in:
Tuukka Turto 2017-03-19 22:27:06 +02:00
commit 61f4277104
3 changed files with 27 additions and 16 deletions

2
NEWS
View File

@ -17,6 +17,8 @@ Changes from 0.12.1
* partition no longer prematurely exhausts input iterators
* read and read-str no longer raise an error when the input
parses to a false value (e.g., the empty string)
* A `yield` inside of a `with` statement will properly suppress implicit
returns.
Changes from 0.12.0

View File

@ -1485,6 +1485,7 @@ class HyASTCompiler(object):
optional_vars=thing)]
ret = ctx + the_with
ret.contains_yield = ret.contains_yield or body.contains_yield
# And make our expression context our temp variable
expr_name = ast.Name(id=ast_str(var), arg=ast_str(var),
ctx=ast.Load(),

View File

@ -727,6 +727,14 @@
(with [(open "README.md" "r")] (do)))
(defn test-context-yield []
"NATIVE: test yields inside of with statements don't try to return before Python 3.3"
(defn f []
(with [(open "README.md")] (yield 123)))
(assert (= (next (f)) 123)))
(defn test-with-return []
"NATIVE: test that with returns stuff"
(defn read-file [filename]