Skip to content

Commit a376715

Browse files
committed
Fallback to identityHashCode when printing pointers
1 parent c3cde6d commit a376715

File tree

1 file changed

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

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3421,7 +3421,16 @@ Object doGeneric(String format, Object vaList) {
34213421
break;
34223422
case 'p':
34233423
// %p
3424-
result.append(getVaArgsNode.getVoidPtr(vaList, vaArgIdx).toString());
3424+
Object ptr = getVaArgsNode.getVoidPtr(vaList, vaArgIdx);
3425+
long value;
3426+
if (interopLibrary.isPointer(ptr)) {
3427+
value = interopLibrary.asPointer(ptr);
3428+
} else if (interopLibrary.hasIdentity(ptr)) {
3429+
value = interopLibrary.identityHashCode(ptr);
3430+
} else {
3431+
value = System.identityHashCode(ptr);
3432+
}
3433+
result.append(String.format("0x%x", value));
34253434
vaArgIdx++;
34263435
valid = true;
34273436
break;

0 commit comments

Comments
 (0)