Skip to content

Commit 9946334

Browse files
author
Christopher Doris
committed
revert JlWrap since that's where the bug seems to be
1 parent 711e338 commit 9946334

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

src/JlWrap/C.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,11 @@ function __init__()
337337
init_c()
338338
end
339339

340-
PyJuliaValue_IsNull(o) = Base.GC.@preserve o UnsafePtr{PyJuliaValueObject}(C.asptr(o)).value[] == 0
340+
PyJuliaValue_IsNull(o::C.PyPtr) = UnsafePtr{PyJuliaValueObject}(o).value[] == 0
341341

342-
PyJuliaValue_GetValue(o) = Base.GC.@preserve o PYJLVALUES[UnsafePtr{PyJuliaValueObject}(C.asptr(o)).value[]]
342+
PyJuliaValue_GetValue(o::C.PyPtr) = PYJLVALUES[UnsafePtr{PyJuliaValueObject}(o).value[]]
343343

344-
PyJuliaValue_SetValue(_o, @nospecialize(v)) = Base.GC.@preserve _o begin
345-
o = C.asptr(_o)
344+
PyJuliaValue_SetValue(o::C.PyPtr, @nospecialize(v)) = begin
346345
idx = UnsafePtr{PyJuliaValueObject}(o).value[]
347346
if idx == 0
348347
if isempty(PYJLFREEVALUES)
@@ -359,8 +358,7 @@ PyJuliaValue_SetValue(_o, @nospecialize(v)) = Base.GC.@preserve _o begin
359358
nothing
360359
end
361360

362-
PyJuliaValue_New(_t, @nospecialize(v)) = Base.GC.@preserve _t begin
363-
t = C.asptr(_t)
361+
PyJuliaValue_New(t::C.PyPtr, @nospecialize(v)) = begin
364362
if C.PyType_IsSubtype(t, PyJuliaBase_Type[]) != 1
365363
C.PyErr_SetString(
366364
C.POINTERS.PyExc_TypeError,

src/JlWrap/base.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const pyjlbasetype = pynew()
22

3-
_pyjl_getvalue(x) = @autopy x Cjl.PyJuliaValue_GetValue(x_)
3+
_pyjl_getvalue(x) = @autopy x Cjl.PyJuliaValue_GetValue(getptr(x_))
44

5-
_pyjl_setvalue!(x, v) = @autopy x Cjl.PyJuliaValue_SetValue(x_, v)
5+
_pyjl_setvalue!(x, v) = @autopy x Cjl.PyJuliaValue_SetValue(getptr(x_), v)
66

7-
pyjl(t, v) = pynew(errcheck(@autopy t Cjl.PyJuliaValue_New(t_, v)))
7+
pyjl(t, v) = pynew(errcheck(@autopy t Cjl.PyJuliaValue_New(getptr(t_), v)))
88

99
"""
1010
pyisjl(x)
@@ -16,7 +16,7 @@ export pyisjl
1616

1717
pyjlisnull(x) = @autopy x begin
1818
if pyisjl(x_)
19-
Cjl.PyJuliaValue_IsNull(x_)
19+
Cjl.PyJuliaValue_IsNull(getptr(x_))
2020
else
2121
error("Expecting a 'juliacall.ValueBase', got a '$(pytype(x_).__name__)'")
2222
end
@@ -85,13 +85,13 @@ function Cjl._pyjl_callmethod(f, self_::C.PyPtr, args_::C.PyPtr, nargs::C.Py_ssi
8585
"__jl_callmethod not implemented for this many arguments",
8686
)
8787
end
88-
return getptr(incref(ans))
88+
return incref(getptr(ans))
8989
catch exc
9090
if exc isa PyException
9191
Base.GC.@preserve exc C.PyErr_Restore(
92-
incref(exc._t),
93-
incref(exc._v),
94-
incref(exc._b),
92+
incref(getptr(exc._t)),
93+
incref(getptr(exc._v)),
94+
incref(getptr(exc._b)),
9595
)
9696
return C.PyNULL
9797
else
@@ -126,7 +126,7 @@ function pyjl_handle_error(f, self, exc)
126126
return C.PyNULL
127127
else
128128
# Otherwise, return the given object (e.g. NotImplemented)
129-
return getptr(incref(t))
129+
return Base.GC.@preserve t incref(getptr(t))
130130
end
131131
end
132132

src/JlWrap/io.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function pyjlbinaryio_readinto(io::IO, b::Py)
102102
return PyNULL
103103
end
104104
pydel!(c)
105-
buf = unsafe_load(C.PyMemoryView_GET_BUFFER(m))
105+
buf = unsafe_load(C.PyMemoryView_GET_BUFFER(getptr(m)))
106106
if buf.readonly != 0
107107
pydel!(m)
108108
errset(pybuiltins.ValueError, "output buffer is read-only")
@@ -125,7 +125,7 @@ function pyjlbinaryio_write(io::IO, b::Py)
125125
return PyNULL
126126
end
127127
pydel!(c)
128-
buf = unsafe_load(C.PyMemoryView_GET_BUFFER(m))
128+
buf = unsafe_load(C.PyMemoryView_GET_BUFFER(getptr(m)))
129129
data = unsafe_wrap(Array, Ptr{UInt8}(buf.buf), buf.len)
130130
write(io, data)
131131
pydel!(m)

src/JlWrap/objectarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ end
5151
@boundscheck checkbounds(x, i...)
5252
v_ = Py(v)
5353
@inbounds decref(x.ptrs[i...])
54-
@inbounds x.ptrs[i...] = getptr(incref(v_))
54+
@inbounds x.ptrs[i...] = incref(getptr(v_))
5555
return x
5656
end
5757

0 commit comments

Comments
 (0)