Skip to content

Commit add6b15

Browse files
committed
fix get_ob_type for sandboxed execution
1 parent cb1831f commit add6b15

File tree

1 file changed

+12
-6
lines changed
  • graalpython/com.oracle.graal.python.cext/src

1 file changed

+12
-6
lines changed

graalpython/com.oracle.graal.python.cext/src/capi.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,19 @@ void* get_ob_type(PyObject* obj) {
235235
if (!truffle_cannot_be_handle(type)) {
236236
return resolve_handle(cache, (uint64_t)type);
237237
} else {
238-
// we have stored a handle to the Java class in ob_refcnt
239-
void* handle = (void*)((PyObject*)type)->ob_refcnt;
240-
if (!truffle_cannot_be_handle(handle)) {
241-
return resolve_handle(cache, (uint64_t)handle);
238+
PyObject* cast_type = ((PyObject*)type);
239+
if (!polyglot_is_value(cast_type)) {
240+
// we have stored a handle to the Java class in ob_refcnt
241+
void* handle = (void*)(cast_type->ob_refcnt);
242+
if (!truffle_cannot_be_handle(handle)) {
243+
return resolve_handle(cache, (uint64_t)handle);
244+
} else {
245+
// assume handle is a TruffleObject
246+
return handle;
247+
}
242248
} else {
243-
// assume handle is a TruffleObject
244-
return handle;
249+
// the type is already the right value (e.g. on sandboxed it's a managed pointer)
250+
return cast_type;
245251
}
246252
}
247253
}

0 commit comments

Comments
 (0)