Skip to content

Commit 5f141ee

Browse files
authored
avoid jl_value_ptr (#671)
* avoid jl_value_ptr * use pointer_from_objref to avoid rooting requirement for unsafe_convert
1 parent f70fe69 commit 5f141ee

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/pytype.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,10 @@ const Py_TPFLAGS_HAVE_STACKLESS_EXTENSION = Ref(0x00000000)
413413
function pyjlwrap_type!(init::Function, to::PyTypeObject, name::AbstractString)
414414
sz = sizeof(Py_jlWrap) + sizeof(PyPtr) # must be > base type
415415
PyTypeObject!(to, name, sz) do t::PyTypeObject
416-
# need Any here: see JuliaLang/julia#31473 and #670
417-
t.tp_base = ccall(:jl_value_ptr, Ptr{Cvoid}, (Any,), jlWrapType)
418-
ccall((@pysym :Py_IncRef), Cvoid, (Any,), jlWrapType)
416+
# We want tp_base to be a pointer to the C-like PyTypeObject struct.
417+
# This is equivalent to the jl_value_t* in Julia (see JuliaLang/julia#31473).
418+
t.tp_base = pointer_from_objref(jlWrapType)
419+
ccall((@pysym :Py_IncRef), Cvoid, (Ref{PyTypeObject},), jlWrapType)
419420
init(t)
420421
end
421422
end

0 commit comments

Comments
 (0)