File tree Expand file tree Collapse file tree 2 files changed +12
-14
lines changed
com.oracle.graal.python.test/src/tests
com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -301,3 +301,13 @@ def f(a):
301
301
302
302
def test_locals_is_globals (self ):
303
303
exec ("assert locals() is globals()" , globals ())
304
+
305
+ def test_custom_locals2 (self ):
306
+ class M (object ):
307
+ def __getitem__ (self , key ):
308
+ return key
309
+ m = M ()
310
+ ns = {}
311
+ exec ("global x; x = y" , ns , m )
312
+ assert ns ["x" ] == "y" ;
313
+ assert eval ("x" , None , m ) == "x"
Original file line number Diff line number Diff line change @@ -475,7 +475,6 @@ public abstract static class EvalNode extends PythonBuiltinNode {
475
475
@ Child protected CompileNode compileNode = CompileNode .create ();
476
476
@ Child private IndirectCallNode indirectCallNode = IndirectCallNode .create ();
477
477
@ Child private HasInheritedAttributeNode hasGetItemNode ;
478
- @ Child private HasInheritedAttributeNode hasSetItemNode ;
479
478
480
479
private HasInheritedAttributeNode getHasGetItemNode () {
481
480
if (hasGetItemNode == null ) {
@@ -485,24 +484,13 @@ private HasInheritedAttributeNode getHasGetItemNode() {
485
484
return hasGetItemNode ;
486
485
}
487
486
488
- private HasInheritedAttributeNode getHasSetItemNode () {
489
- if (hasSetItemNode == null ) {
490
- CompilerDirectives .transferToInterpreterAndInvalidate ();
491
- hasSetItemNode = insert (HasInheritedAttributeNode .create (SpecialMethodNames .__SETITEM__ ));
492
- }
493
- return hasSetItemNode ;
494
- }
495
-
496
487
protected boolean isMapping (Object object ) {
497
- // tfel: it seems that CPython only checks that there is __getitem__ and __setitem__
488
+ // tfel: it seems that CPython only checks that there is __getitem__
498
489
if (object instanceof PDict ) {
499
490
return true ;
500
491
} else {
501
- if (getHasGetItemNode ().execute (object )) {
502
- return getHasSetItemNode ().execute (object );
503
- }
492
+ return getHasGetItemNode ().execute (object );
504
493
}
505
- return false ;
506
494
}
507
495
508
496
protected boolean isAnyNone (Object object ) {
You can’t perform that action at this time.
0 commit comments