Skip to content

Commit bebfafe

Browse files
committed
Fix long initializer for 'array.array'.
1 parent 9cdb59a commit bebfafe

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ PArray arrayLongInitializer(PythonClass cls, @SuppressWarnings("unused") String
193193
e.expectStopIteration(getCore(), errorProfile);
194194
break;
195195
}
196-
if (nextValue instanceof Long) {
197-
longArray[i++] = (long) nextValue;
196+
if (nextValue instanceof Number) {
197+
longArray[i++] = longValue((Number) nextValue);
198198
} else {
199199
throw raise(ValueError, "integer argument expected, got %p", nextValue);
200200
}
@@ -244,6 +244,11 @@ PArray arrayWithObjectInitializer(@SuppressWarnings("unused") PythonClass cls, @
244244
throw new RuntimeException("Unsupported initializer " + initializer);
245245
}
246246

247+
@TruffleBoundary
248+
private static long longValue(Number n) {
249+
return n.longValue();
250+
}
251+
247252
private PArray makeEmptyArray(PythonClass cls, char type) {
248253
switch (type) {
249254
case 'c':

0 commit comments

Comments
 (0)