Skip to content

Commit 6a7de77

Browse files
committed
simplify hash*iterator exports
1 parent 82789d4 commit 6a7de77

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/PDict.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import static com.oracle.graal.python.nodes.SpecialMethodNames.ITEMS;
2929
import static com.oracle.graal.python.nodes.SpecialMethodNames.KEYS;
3030
import static com.oracle.graal.python.nodes.SpecialMethodNames.VALUES;
31-
import static com.oracle.graal.python.nodes.SpecialMethodNames.__ITER__;
3231
import static com.oracle.graal.python.nodes.SpecialMethodNames.__LEN__;
3332

3433
import com.oracle.graal.python.PythonLanguage;
@@ -232,20 +231,20 @@ static void removeHashEntry(PDict self, Object key,
232231
static Object getHashEntriesIterator(PDict self,
233232
@Shared("iterLib") @CachedLibrary(limit = "2") PythonObjectLibrary lib) {
234233
Object dictItems = lib.lookupAndCallSpecialMethod(self, null, ITEMS);
235-
return lib.lookupAndCallSpecialMethod(dictItems, null, __ITER__);
234+
return lib.getIterator(dictItems);
236235
}
237236

238237
@ExportMessage
239238
static Object getHashKeysIterator(PDict self,
240239
@Shared("iterLib") @CachedLibrary(limit = "2") PythonObjectLibrary lib) {
241-
Object dictItems = lib.lookupAndCallSpecialMethod(self, null, KEYS);
242-
return lib.lookupAndCallSpecialMethod(dictItems, null, __ITER__);
240+
Object dictKeys = lib.lookupAndCallSpecialMethod(self, null, KEYS);
241+
return lib.getIterator(dictKeys);
243242
}
244243

245244
@ExportMessage
246245
static Object getHashValuesIterator(PDict self,
247246
@Shared("iterLib") @CachedLibrary(limit = "2") PythonObjectLibrary lib) {
248-
Object dictItems = lib.lookupAndCallSpecialMethod(self, null, VALUES);
249-
return lib.lookupAndCallSpecialMethod(dictItems, null, __ITER__);
247+
Object dictValues = lib.lookupAndCallSpecialMethod(self, null, VALUES);
248+
return lib.getIterator(dictValues);
250249
}
251250
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/foreign/AccessForeignItemNodes.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ Object doHashKey(Object object, Object key,
189189
throw CompilerDirectives.shouldNotReachHere(e);
190190
}
191191
}
192-
throw raise(KeyError, lib.toDisplayString(key, true));
192+
try {
193+
throw raise(KeyError, lib.asString(lib.toDisplayString(key, true)));
194+
} catch (UnsupportedMessageException e) {
195+
throw CompilerDirectives.shouldNotReachHere(e);
196+
}
193197
}
194198

195199
@Fallback
@@ -292,7 +296,11 @@ Object doHashKey(Object object, Object key, Object value,
292296
}
293297
}
294298
wrongIndex.enter();
295-
throw raise(KeyError, lib.toDisplayString(key, true));
299+
try {
300+
throw raise(KeyError, lib.asString(lib.toDisplayString(key, true)));
301+
} catch (UnsupportedMessageException e) {
302+
throw CompilerDirectives.shouldNotReachHere(e);
303+
}
296304
}
297305

298306
@Fallback
@@ -372,7 +380,11 @@ Object doHashKey(Object object, Object key,
372380
throw CompilerDirectives.shouldNotReachHere(e);
373381
}
374382
}
375-
throw raise(KeyError, lib.toDisplayString(key, true));
383+
try {
384+
throw raise(KeyError, lib.asString(lib.toDisplayString(key, true)));
385+
} catch (UnsupportedMessageException e) {
386+
throw CompilerDirectives.shouldNotReachHere(e);
387+
}
376388
}
377389

378390
@Fallback

0 commit comments

Comments
 (0)