Skip to content

Commit af2e19e

Browse files
committed
in a generator, the locals() call should give the generator frame locals
1 parent a48de05 commit af2e19e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1785,11 +1785,17 @@ public Object globals(VirtualFrame frame) {
17851785
abstract static class LocalsNode extends PythonBuiltinNode {
17861786
@Child ReadCallerFrameNode readCallerFrameNode = ReadCallerFrameNode.create();
17871787
@Child GetLocalsNode getLocalsNode = GetLocalsNode.create();
1788+
private final ConditionProfile inGenerator = ConditionProfile.createBinaryProfile();
17881789

17891790
@Specialization
17901791
public Object locals(VirtualFrame frame) {
17911792
Frame callerFrame = readCallerFrameNode.executeWith(frame);
1792-
return getLocalsNode.execute(callerFrame);
1793+
Frame generatorFrame = PArguments.getGeneratorFrame(callerFrame);
1794+
if (inGenerator.profile(generatorFrame == null)) {
1795+
return getLocalsNode.execute(callerFrame);
1796+
} else {
1797+
return getLocalsNode.execute(generatorFrame);
1798+
}
17931799
}
17941800
}
17951801
}

0 commit comments

Comments
 (0)