diff --git a/src/GC/GC.jl b/src/GC/GC.jl index e7e992a6..92beae95 100644 --- a/src/GC/GC.jl +++ b/src/GC/GC.jl @@ -103,7 +103,7 @@ function enqueue(ptr::C.PyPtr) end function enqueue_all(ptrs) - if any(!=(C.PYNULL), ptrs) && C.CTX.is_initialized + if any(!=(C.PyNULL), ptrs) && C.CTX.is_initialized if C.PyGILState_Check() == 1 for ptr in ptrs if ptr != C.PyNULL diff --git a/test/JlWrap.jl b/test/JlWrap.jl index f0a20be9..3505c2c5 100644 --- a/test/JlWrap.jl +++ b/test/JlWrap.jl @@ -577,4 +577,13 @@ end @test pyeq(Bool, x.count(nothing), 0) @test pyeq(Bool, x.count("2"), 0) end + + @testset "PyObjectArray" begin + # https://github.com/JuliaPy/PythonCall.jl/issues/543 + # Here we check the finalizer does not error + # We must not reuse `arr` in this code once we finalize it! + let arr = PyObjectArray([1, 2, 3]) + finalize(arr) + end + end end