Skip to content

Commit 702b1ef

Browse files
committed
fix broken callbacks - deal with Julia pickiness in assigning C_NULL to PyPtr
1 parent b38e11a commit 702b1ef

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/PyCall.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function pydecref(o::PyObject)
8686
if initialized::Bool # don't decref after pyfinalize!
8787
ccall((@pysym :Py_DecRef), Void, (PyPtr,), o.o)
8888
end
89-
o.o = C_NULL
89+
o.o = convert(PyPtr, C_NULL)
9090
o
9191
end
9292

src/callback.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ function jl_Function_call(self_::PyPtr, args_::PyPtr, kw_::PyPtr)
4343
f = unsafe_pyjlwrap_to_objref(self_)::Function
4444
ret = PyObject(f(convert(PyAny, args)...))
4545
ret_ = ret.o
46-
ret.o = C_NULL # don't decref
46+
ret.o = convert(PyPtr, C_NULL) # don't decref
4747
catch e
4848
ccall((@pysym :PyErr_SetString), Void, (PyPtr, Ptr{Uint8}),
4949
(@pysym :PyExc_RuntimeError),
5050
bytestring(string("Julia exception: ", e)))
5151
finally
52-
args.o = C_NULL # don't decref
52+
args.o = convert(PyPtr, C_NULL) # don't decref
5353
end
5454
return ret_::PyPtr
5555
end

src/pytype.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ function pyjlwrap_repr(o::PyPtr)
332332
o = PyObject(try string("<PyCall.jlwrap ",unsafe_pyjlwrap_to_objref(o),">")
333333
catch "<PyCall.jlwrap NULL>"; end)
334334
oret = o.o
335-
o.o = C_NULL # don't decref
335+
o.o = convert(PyPtr, C_NULL) # don't decref
336336
return oret
337337
end
338338

0 commit comments

Comments
 (0)