Skip to content

Commit 9309245

Browse files
committed
Fix lambda generators: StopIteration should wrap last sent value
1 parent 826bb6a commit 9309245

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags_bytecode_dsl/test_generators.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ test.test_generators.ExceptionTest.test_return_stopiteration @ linux-x86_64
1717
test.test_generators.ExceptionTest.test_return_tuple @ linux-x86_64
1818
test.test_generators.ExceptionTest.test_stopiteration_error @ linux-x86_64
1919
test.test_generators.ExceptionTest.test_tutorial_stopiteration @ linux-x86_64
20+
test.test_generators.FinalizationTest.test_lambda_generator @ linux-x86_64
2021
test.test_generators.GeneratorStackTraceTest.test_send_with_yield_from @ linux-x86_64
2122
test.test_generators.GeneratorStackTraceTest.test_throw_with_yield_from @ linux-x86_64
2223
test.test_generators.GeneratorTest.test_copy @ linux-x86_64

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,10 +926,10 @@ private BytecodeDSLCompilerResult compileTypeAliasTypeParameters(String name, By
926926
@Override
927927
public BytecodeDSLCompilerResult visit(ExprTy.Lambda node) {
928928
return compileRootNode("<lambda>", ArgumentInfo.fromArguments(node.args), node.getSourceRange(),
929-
b -> emitFunctionDefBody(node, node.args, new SSTNode[]{node.body}, b, null, !scope.isGenerator()));
929+
b -> emitFunctionDefBody(node, node.args, new SSTNode[]{node.body}, b, null, true));
930930
}
931931

932-
private void emitFunctionDefBody(SSTNode node, ArgumentsTy args, SSTNode[] body, Builder b, Object docstring, boolean isRegularLambda) {
932+
private void emitFunctionDefBody(SSTNode node, ArgumentsTy args, SSTNode[] body, Builder b, Object docstring, boolean isLambda) {
933933
beginRootNode(node, args, b);
934934

935935
int i = 0;
@@ -946,7 +946,7 @@ private void emitFunctionDefBody(SSTNode node, ArgumentsTy args, SSTNode[] body,
946946

947947
StatementCompiler statementCompiler = new StatementCompiler(b);
948948

949-
if (isRegularLambda) {
949+
if (isLambda) {
950950
assert i == 0;
951951
assert body[0] instanceof ExprTy;
952952
beginReturn(b);

0 commit comments

Comments
 (0)