Skip to content

Commit 00f36f9

Browse files
authored
PyList: fix pushfirst! for Julia 1.11, by adding prepend! (#588)
1 parent a61c022 commit 00f36f9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Wrap/PyList.jl

+7
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ function Base.append!(x::PyList, vs)
6161
return x
6262
end
6363

64+
function Base.prepend!(x::PyList, vs)
65+
for v in reverse(vs)
66+
pushfirst!(x, v)
67+
end
68+
return x
69+
end
70+
6471
function Base.push!(x::PyList, v1, v2, vs...)
6572
push!(x, v1)
6673
push!(x, v2, vs...)

test/Wrap.jl

+7
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,13 @@ end
381381
@test_throws Exception append!(t, [nothing, missing])
382382
@test t == [1, 2, 3, 4, 5, 6]
383383
end
384+
@testset "prepend!" begin
385+
t = copy(z)
386+
@test prepend!(t, [-3, -2, -1]) === t
387+
@test t == [-3, -2, -1, 1, 2, 3]
388+
@test_throws Exception append!(t, [nothing, missing])
389+
@test t == [-3, -2, -1, 1, 2, 3]
390+
end
384391
@testset "pop!" begin
385392
t = copy(z)
386393
@test pop!(t) == 3

0 commit comments

Comments
 (0)