From a52b88bc85f9576263478fe6b58e7bd8eeeb366a Mon Sep 17 00:00:00 2001
From: hhaensel <helmut.haensel@gmx.com>
Date: Sun, 19 Jan 2025 13:16:06 +0100
Subject: [PATCH] PyList: fix pushfirst! for Julia 1.11, by adding prepend!

---
 src/Wrap/PyList.jl | 7 +++++++
 test/Wrap.jl       | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/src/Wrap/PyList.jl b/src/Wrap/PyList.jl
index 69307c3a..d1422d12 100644
--- a/src/Wrap/PyList.jl
+++ b/src/Wrap/PyList.jl
@@ -61,6 +61,13 @@ function Base.append!(x::PyList, vs)
     return x
 end
 
+function Base.prepend!(x::PyList, vs)
+    for v in reverse(vs)
+        pushfirst!(x, v)
+    end
+    return x
+end
+
 function Base.push!(x::PyList, v1, v2, vs...)
     push!(x, v1)
     push!(x, v2, vs...)
diff --git a/test/Wrap.jl b/test/Wrap.jl
index fe8659e3..a1e2a359 100644
--- a/test/Wrap.jl
+++ b/test/Wrap.jl
@@ -381,6 +381,13 @@ end
         @test_throws Exception append!(t, [nothing, missing])
         @test t == [1, 2, 3, 4, 5, 6]
     end
+    @testset "prepend!" begin
+        t = copy(z)
+        @test prepend!(t, [-3, -2, -1]) === t
+        @test t == [-3, -2, -1, 1, 2, 3]
+        @test_throws Exception append!(t, [nothing, missing])
+        @test t == [-3, -2, -1, 1, 2, 3]
+    end
     @testset "pop!" begin
         t = copy(z)
         @test pop!(t) == 3