mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Merged revisions 67954 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r67954 | benjamin.peterson | 2008-12-27 12:24:11 -0600 (Sat, 27 Dec 2008) | 1 line #4748 lambda generators shouldn't return values ........
This commit is contained in:
parent
5cdee16e1f
commit
371ccfb5f5
3 changed files with 18 additions and 1 deletions
|
@ -928,6 +928,16 @@ Test the __name__ attribute and the repr()
|
||||||
'f'
|
'f'
|
||||||
>>> repr(g) # doctest: +ELLIPSIS
|
>>> repr(g) # doctest: +ELLIPSIS
|
||||||
'<generator object f at ...>'
|
'<generator object f at ...>'
|
||||||
|
|
||||||
|
Lambdas shouldn't have their usual return behavior.
|
||||||
|
|
||||||
|
>>> x = lambda: (yield 1)
|
||||||
|
>>> list(x())
|
||||||
|
[1]
|
||||||
|
|
||||||
|
>>> x = lambda: ((yield 1), (yield 2))
|
||||||
|
>>> list(x())
|
||||||
|
[1, 2]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# conjoin is a simple backtracking generator, named in honor of Icon's
|
# conjoin is a simple backtracking generator, named in honor of Icon's
|
||||||
|
|
|
@ -56,6 +56,8 @@ Core and Builtins
|
||||||
- Issue #4569: Interpreter crash when mutating a memoryview with an item size
|
- Issue #4569: Interpreter crash when mutating a memoryview with an item size
|
||||||
larger than 1.
|
larger than 1.
|
||||||
|
|
||||||
|
- Issue #4748: Lambda generators no longer return a value.
|
||||||
|
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
|
@ -1704,7 +1704,12 @@ compiler_lambda(struct compiler *c, expr_ty e)
|
||||||
c->u->u_argcount = asdl_seq_LEN(args->args);
|
c->u->u_argcount = asdl_seq_LEN(args->args);
|
||||||
c->u->u_kwonlyargcount = asdl_seq_LEN(args->kwonlyargs);
|
c->u->u_kwonlyargcount = asdl_seq_LEN(args->kwonlyargs);
|
||||||
VISIT_IN_SCOPE(c, expr, e->v.Lambda.body);
|
VISIT_IN_SCOPE(c, expr, e->v.Lambda.body);
|
||||||
|
if (c->u->u_ste->ste_generator) {
|
||||||
|
ADDOP_IN_SCOPE(c, POP_TOP);
|
||||||
|
}
|
||||||
|
else {
|
||||||
ADDOP_IN_SCOPE(c, RETURN_VALUE);
|
ADDOP_IN_SCOPE(c, RETURN_VALUE);
|
||||||
|
}
|
||||||
co = assemble(c, 1);
|
co = assemble(c, 1);
|
||||||
compiler_exit_scope(c);
|
compiler_exit_scope(c);
|
||||||
if (co == NULL)
|
if (co == NULL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue