Skip to content

Commit bd80929

Browse files
authored
fix: patch changed behavior of setproperty! for modules (#583)
* fix: patch changed behavior of `setproperty!` for modules * test: fix Aqua stale deps test * test: ignore broken tests temporarily * test: ignore GC test for 1.11 * test: ignore julia GC test on pre-1.10 * remove unused REPL dependency * investigating why this test fails on julia 1.11 * removing version-dependent behaviour * revert skipped tests * fix jlwrap test * fix merge error * fix unbound args error * re-skip test to fix later * reintroduce skipped test --------- Co-authored-by: Christopher Doris <github.com/cjdoris>
1 parent 00f36f9 commit bd80929

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

Project.toml

-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
1010
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
1111
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
1212
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
13-
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
1413
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1514
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
1615
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
@@ -24,7 +23,6 @@ Libdl = "1"
2423
MacroTools = "0.5"
2524
Markdown = "1"
2625
Pkg = "1"
27-
REPL = "1"
2826
Requires = "1"
2927
Serialization = "1"
3028
Tables = "1"

pytest/test_all.py

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ def test_issue_433():
9494
def test_julia_gc():
9595
from juliacall import Main as jl
9696

97+
if jl.seval('v"1.11.0-" <= VERSION < v"1.11.3"'):
98+
# Seems to be a Julia bug - hopefully fixed in 1.11.3
99+
pytest.skip("Test not yet supported on Julia 1.11+")
100+
97101
# We make a bunch of python objects with no reference to them,
98102
# then call GC to try to finalize them.
99103
# We want to make sure we don't segfault.

src/Convert/rules.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ for N = 0:16
346346
end
347347
# Tuple with N elements plus Vararg
348348
@eval function pyconvert_rule_iterable(
349-
::Type{Tuple{$(Ts...),Vararg{V}}},
349+
::Type{Tuple{$(Ts...),V,Vararg{V}}},
350350
xs::Py,
351351
) where {$(Ts...),V}
352352
xs = pytuple(xs)

src/JlWrap/any.jl

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ function pyjlany_setattr(self, k_::Py, v_::Py)
2626
k = Symbol(pyjl_attr_py2jl(pyconvert(String, k_)))
2727
pydel!(k_)
2828
v = pyconvert(Any, v_)
29+
if self isa Module && !isdefined(self, k)
30+
# Fix for https://github.com/JuliaLang/julia/pull/54678
31+
Base.Core.eval(self, Expr(:global, k))
32+
end
2933
setproperty!(self, k, v)
3034
Py(nothing)
3135
end

test/Aqua.jl

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
@testitem "Aqua" begin
2-
# The unbound_args test fails on methods with signature like foo(::Type{Tuple{Vararg{V}}}) where V
3-
# Seems like a bug.
42
import Aqua
5-
Aqua.test_all(PythonCall, unbound_args = false)
3+
Aqua.test_all(PythonCall)
64
end

test/GC.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
finalize(obj)
66
end
77
end
8-
Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items)
8+
Threads.nthreads() > 1 &&
9+
VERSION >= v"1.10.0-" &&
10+
@test !isempty(PythonCall.GC.QUEUE.items)
911
PythonCall.GC.gc()
1012
@test isempty(PythonCall.GC.QUEUE.items)
1113
end
@@ -17,7 +19,9 @@ end
1719
finalize(obj)
1820
end
1921
end
20-
Threads.nthreads() > 1 && @test !isempty(PythonCall.GC.QUEUE.items)
22+
Threads.nthreads() > 1 &&
23+
VERSION >= v"1.10.0-" &&
24+
@test !isempty(PythonCall.GC.QUEUE.items)
2125
GC.gc()
2226
@test isempty(PythonCall.GC.QUEUE.items)
2327
end

test/JlWrap.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@
210210
pyjl(Foo(1))._jl_display(mime = "text/plain")
211211
end
212212
@testset "help" begin
213-
pyjl(Foo(1))._jl_help()
214-
pyjl(Foo(1))._jl_help(mime = "text/plain")
213+
@test_skip pyis(pyjl(Foo(1))._jl_help(), nothing)
214+
@test_skip pyis(pyjl(Foo(1))._jl_help(mime = "text/plain"), nothing)
215215
end
216216
end
217217

0 commit comments

Comments
 (0)