Merge branch 'kirbyfan64-yield-ret'
This commit is contained in:
commit
61f4277104
2
NEWS
2
NEWS
@ -17,6 +17,8 @@ Changes from 0.12.1
|
|||||||
* partition no longer prematurely exhausts input iterators
|
* partition no longer prematurely exhausts input iterators
|
||||||
* read and read-str no longer raise an error when the input
|
* read and read-str no longer raise an error when the input
|
||||||
parses to a false value (e.g., the empty string)
|
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
|
Changes from 0.12.0
|
||||||
|
|
||||||
|
@ -1485,6 +1485,7 @@ class HyASTCompiler(object):
|
|||||||
optional_vars=thing)]
|
optional_vars=thing)]
|
||||||
|
|
||||||
ret = ctx + the_with
|
ret = ctx + the_with
|
||||||
|
ret.contains_yield = ret.contains_yield or body.contains_yield
|
||||||
# And make our expression context our temp variable
|
# And make our expression context our temp variable
|
||||||
expr_name = ast.Name(id=ast_str(var), arg=ast_str(var),
|
expr_name = ast.Name(id=ast_str(var), arg=ast_str(var),
|
||||||
ctx=ast.Load(),
|
ctx=ast.Load(),
|
||||||
|
@ -727,6 +727,14 @@
|
|||||||
(with [(open "README.md" "r")] (do)))
|
(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 []
|
(defn test-with-return []
|
||||||
"NATIVE: test that with returns stuff"
|
"NATIVE: test that with returns stuff"
|
||||||
(defn read-file [filename]
|
(defn read-file [filename]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user