From b125039c36d537207f67095dae7236dba9660799 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Wed, 21 Aug 2024 23:19:29 +0200 Subject: [PATCH 1/2] fix PyNULL typo --- src/GC/GC.jl | 2 +- test/JlWrap.jl | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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..f133968a 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([pylist([1]), pylist([2])]) + PythonCall.JlWrap.pyobjectarray_finalizer(arr) + end + end end From 5b9e97707eb9c16d6daf36c560861548826a4067 Mon Sep 17 00:00:00 2001 From: Christopher Doris Date: Thu, 22 Aug 2024 20:16:13 +0100 Subject: [PATCH 2/2] simplify PyObjectArray finalizer gc test --- test/JlWrap.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/JlWrap.jl b/test/JlWrap.jl index f133968a..3505c2c5 100644 --- a/test/JlWrap.jl +++ b/test/JlWrap.jl @@ -582,8 +582,8 @@ end # 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([pylist([1]), pylist([2])]) - PythonCall.JlWrap.pyobjectarray_finalizer(arr) + let arr = PyObjectArray([1, 2, 3]) + finalize(arr) end end end