File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
com.oracle.graal.python.test/src/tests
com.oracle.graal.python/src/com/oracle/graal/python/nodes/object Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ def t(obj):
146
146
self .assertEqual (t (True ), polyglot .ForeignBoolean )
147
147
self .assertEqual (t (BaseException ()), polyglot .ForeignException )
148
148
self .assertEqual (t (lambda : None ), polyglot .ForeignExecutable )
149
- self .assertEqual (t ({}), polyglot .ForeignDictIterable ) # TODO
149
+ self .assertEqual (t ({}), polyglot .ForeignDict )
150
150
# ForeignInstantiable
151
151
self .assertEqual (t ((e for e in [1 ])), polyglot .ForeignIteratorIterable )
152
152
self .assertEqual (t (iter ([1 ])), polyglot .ForeignIteratorIterable )
Original file line number Diff line number Diff line change @@ -181,17 +181,21 @@ private PythonManagedClass resolvePolyglotForeignClassAndSetInCache(int traits)
181
181
182
182
// Special naming rules:
183
183
// Foreign...Instantiable...AbstractClass -> Foreign......Class
184
- // Foreign...List...Iterable -> Foreign...List... (since all Python lists are iterables)
184
+ // Foreign...List...Iterable -> Foreign...List... (since all Python lists are iterable)
185
+ // Foreign...Dict...Iterable -> Foreign...Dict... (since all Python dicts are iterable)
185
186
@ TruffleBoundary
186
187
private PythonManagedClass resolvePolyglotForeignClass (int traits ) {
187
188
PythonBuiltinClass base = getContext ().lookupType (PythonBuiltinClassType .ForeignObject );
188
189
if (traits == 0 ) {
189
190
return base ;
190
191
}
191
192
192
- // For foreign array+iterable, ignore the iterable trait completely, foreign arrays inherit
193
- // from the Python list class and all lists are iterables (they have __iter__)
194
- if (Trait .ARRAY .isSet (traits ) && Trait .ITERABLE .isSet (traits )) {
193
+ /*
194
+ * For foreign array/hash+iterable, ignore the iterable trait completely, foreign
195
+ * arrays/hashes inherit from the Python list/dict class and all lists/dicts are iterables
196
+ * (they have __iter__)
197
+ */
198
+ if ((Trait .ARRAY .isSet (traits ) || Trait .HASH .isSet (traits )) && Trait .ITERABLE .isSet (traits )) {
195
199
return classForTraits (traits - Trait .ITERABLE .bit );
196
200
}
197
201
You can’t perform that action at this time.
0 commit comments