Skip to content

Commit

Permalink
avoid jl_value_ptr (#671)
Browse files Browse the repository at this point in the history
* avoid jl_value_ptr

* use pointer_from_objref to avoid rooting requirement for unsafe_convert
  • Loading branch information
stevengj committed Mar 26, 2019
1 parent f70fe69 commit 5f141ee
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/pytype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,10 @@ const Py_TPFLAGS_HAVE_STACKLESS_EXTENSION = Ref(0x00000000)
function pyjlwrap_type!(init::Function, to::PyTypeObject, name::AbstractString)
sz = sizeof(Py_jlWrap) + sizeof(PyPtr) # must be > base type
PyTypeObject!(to, name, sz) do t::PyTypeObject
# need Any here: see JuliaLang/julia#31473 and #670
t.tp_base = ccall(:jl_value_ptr, Ptr{Cvoid}, (Any,), jlWrapType)
ccall((@pysym :Py_IncRef), Cvoid, (Any,), jlWrapType)
# We want tp_base to be a pointer to the C-like PyTypeObject struct.
# This is equivalent to the jl_value_t* in Julia (see JuliaLang/julia#31473).
t.tp_base = pointer_from_objref(jlWrapType)
ccall((@pysym :Py_IncRef), Cvoid, (Ref{PyTypeObject},), jlWrapType)
init(t)
end
end
Expand Down

0 comments on commit 5f141ee

Please sign in to comment.