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):
301301
302302 def test_locals_is_globals (self ):
303303 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 {
475475 @ Child protected CompileNode compileNode = CompileNode .create ();
476476 @ Child private IndirectCallNode indirectCallNode = IndirectCallNode .create ();
477477 @ Child private HasInheritedAttributeNode hasGetItemNode ;
478- @ Child private HasInheritedAttributeNode hasSetItemNode ;
479478
480479 private HasInheritedAttributeNode getHasGetItemNode () {
481480 if (hasGetItemNode == null ) {
@@ -485,24 +484,13 @@ private HasInheritedAttributeNode getHasGetItemNode() {
485484 return hasGetItemNode ;
486485 }
487486
488- private HasInheritedAttributeNode getHasSetItemNode () {
489- if (hasSetItemNode == null ) {
490- CompilerDirectives .transferToInterpreterAndInvalidate ();
491- hasSetItemNode = insert (HasInheritedAttributeNode .create (SpecialMethodNames .__SETITEM__ ));
492- }
493- return hasSetItemNode ;
494- }
495-
496487 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__
498489 if (object instanceof PDict ) {
499490 return true ;
500491 } else {
501- if (getHasGetItemNode ().execute (object )) {
502- return getHasSetItemNode ().execute (object );
503- }
492+ return getHasGetItemNode ().execute (object );
504493 }
505- return false ;
506494 }
507495
508496 protected boolean isAnyNone (Object object ) {
You can’t perform that action at this time.
0 commit comments