Skip to content

Commit 2121364

Browse files
author
Christopher Doris
committed
more preserve
1 parent 4b58458 commit 2121364

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/JlWrap/objectarray.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ end
4242

4343
@propagate_inbounds function Base.getindex(x::PyObjectArray, i::Integer...)
4444
@boundscheck checkbounds(x, i...)
45-
@inbounds ptr = x.ptrs[i...]
46-
ptr == C_NULL && throw(UndefRefError())
47-
return pynew(incref(ptr))
45+
Base.GC.@preserve x begin
46+
@inbounds ptr = x.ptrs[i...]
47+
ptr == C_NULL && throw(UndefRefError())
48+
return pynew(incref(ptr))
49+
end
4850
end
4951

5052
@propagate_inbounds function Base.setindex!(x::PyObjectArray, v, i::Integer...)

0 commit comments

Comments
 (0)