Skip to content

Commit 82f4b02

Browse files
committed
Fix: ObSizeNode did not handle PythonNativeVoidPtr
1 parent 90c1329 commit 82f4b02

File tree

1 file changed

+7
-1
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3195,6 +3195,12 @@ long doPInt(PInt object) {
31953195
return ((PInt.bitLength(object.abs()) - 1) / PythonContext.get(this).getCApiContext().getPyLongBitsInDigit() + 1) * (object.isNegative() ? -1 : 1);
31963196
}
31973197

3198+
@Specialization
3199+
static long doPythonNativeVoidPtr(@SuppressWarnings("unused") PythonNativeVoidPtr object,
3200+
@Shared("context") @CachedContext(PythonLanguage.class) PythonContext context) {
3201+
return ((Long.SIZE - 1) / context.getCApiContext().getPyLongBitsInDigit() + 1);
3202+
}
3203+
31983204
@Specialization(guards = "isFallback(object)")
31993205
static long doOther(Object object,
32003206
@Cached PyObjectSizeNode sizeNode) {
@@ -3206,7 +3212,7 @@ static long doOther(Object object,
32063212
}
32073213

32083214
static boolean isFallback(Object object) {
3209-
return !(object instanceof PInt || object instanceof Integer || object instanceof Long);
3215+
return !(object instanceof PInt || object instanceof Integer || object instanceof Long || object instanceof PythonNativeVoidPtr);
32103216
}
32113217
}
32123218

0 commit comments

Comments
 (0)