[Python-checkins] r67959 - in python/branches/py3k: Lib/test/test_generators.py Misc/NEWS Python/compile.c
benjamin.peterson
python-checkins at python.org
Sat Dec 27 20:03:37 CET 2008
Author: benjamin.peterson
Date: Sat Dec 27 20:03:36 2008
New Revision: 67959
Log:
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
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/test/test_generators.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/Python/compile.c
Modified: python/branches/py3k/Lib/test/test_generators.py
==============================================================================
--- python/branches/py3k/Lib/test/test_generators.py (original)
+++ python/branches/py3k/Lib/test/test_generators.py Sat Dec 27 20:03:36 2008
@@ -928,6 +928,16 @@
'f'
>>> repr(g) # doctest: +ELLIPSIS
'<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
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Sat Dec 27 20:03:36 2008
@@ -56,6 +56,8 @@
- Issue #4569: Interpreter crash when mutating a memoryview with an item size
larger than 1.
+- Issue #4748: Lambda generators no longer return a value.
+
Library
-------
Modified: python/branches/py3k/Python/compile.c
==============================================================================
--- python/branches/py3k/Python/compile.c (original)
+++ python/branches/py3k/Python/compile.c Sat Dec 27 20:03:36 2008
@@ -1704,7 +1704,12 @@
c->u->u_argcount = asdl_seq_LEN(args->args);
c->u->u_kwonlyargcount = asdl_seq_LEN(args->kwonlyargs);
VISIT_IN_SCOPE(c, expr, e->v.Lambda.body);
- ADDOP_IN_SCOPE(c, RETURN_VALUE);
+ if (c->u->u_ste->ste_generator) {
+ ADDOP_IN_SCOPE(c, POP_TOP);
+ }
+ else {
+ ADDOP_IN_SCOPE(c, RETURN_VALUE);
+ }
co = assemble(c, 1);
compiler_exit_scope(c);
if (co == NULL)
More information about the Python-checkins
mailing list