Skip to content

Commit fc1180f

Browse files
committed
PyLongDigitsWrapper (ob_digits) fix PInt case
1 parent b6ba621 commit fc1180f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PyLongDigitsWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ final Object readArrayElement(long index,
142142
}
143143
return (val >> (longShift * index)) & longMask;
144144
} else {
145-
byte[] bytes = ((PInt) delegate).toByteArray();
145+
byte[] bytes = ((PInt) delegate).abs().toByteArray();
146146
// the cast to int is safe since the length check already succeeded
147-
return getUInt32(bytes, (int) index, longShift);
147+
return getUInt32(bytes, (int) index, longShift) & longMask;
148148
}
149149
}
150150
throw InvalidArrayIndexException.create(index);

0 commit comments

Comments
 (0)