Skip to content

Commit 14df767

Browse files
committed
locals() in a class scope should return the namespace locals
1 parent 97929f2 commit 14df767

File tree

1 file changed

+8
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame

1 file changed

+8
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/FrameBuiltins.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.oracle.graal.python.builtins.objects.object.ObjectBuiltinsFactory.DictNodeFactory;
4242
import com.oracle.graal.python.builtins.objects.object.PythonObject;
4343
import com.oracle.graal.python.builtins.objects.traceback.PTraceback;
44+
import com.oracle.graal.python.nodes.function.ClassBodyRootNode;
4445
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
4546
import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
4647
import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
@@ -171,7 +172,13 @@ Object getFromFrame(Frame owner,
171172
@Cached("create()") BranchProfile noFrameOnPFrame) {
172173
PFrame pFrame = PArguments.getPFrame(owner);
173174
if (noPFrame.profile(pFrame == null)) {
174-
pFrame = factory().createPFrame(owner);
175+
Object specialArgument = PArguments.getSpecialArgument(owner);
176+
if (specialArgument instanceof ClassBodyRootNode) {
177+
// the namespace argument stores the locals
178+
pFrame = factory().createPFrame(owner, PArguments.getArgument(owner, 0));
179+
} else {
180+
pFrame = factory().createPFrame(owner);
181+
}
175182
PArguments.setPFrame(owner, pFrame);
176183
} else if (!pFrame.hasFrame()) {
177184
noFrameOnPFrame.enter();

0 commit comments

Comments
 (0)