Package: release.debian.org
Severity: normal
Tags: trixie
User: [email protected]
Usertags: pu
X-Debbugs-Cc: [email protected][email protected], [email protected]
Control: affects -1 + src:python3-lxc

[ Reason ]
It turns out that the Python 3 bindings for lxc don't actually work
with Python 3.13+ due to depending on deprecated functions in the
Python C bindings. This cherry-picks the small upstream patch to fix
things.

[ Impact ]
The lxc Python bindings are broken in trixie.

[ Tests ]
A small POC is provided at
https://github.com/lxc/python3-lxc/issues/35, which I've verified
currently fails in trixie, but works as expected with the patch
applied.

[ Risks ]
Minor/none -- one targeted fix cherry-picked from the upstream git
repo.

[ Checklist ]
  [*] *all* changes are documented in the d/changelog
  [*] I reviewed all changes and I approve them
  [*] attach debdiff against the package in (old)stable
  [*] the issue is verified as fixed in unstable

[ Changes ]
One patch as outlined above.

[ Other info ]
The source debdiff is attached.
diff -Nru python3-lxc-5.0.0/debian/changelog python3-lxc-5.0.0/debian/changelog
--- python3-lxc-5.0.0/debian/changelog	2024-04-14 01:13:37.000000000 +0000
+++ python3-lxc-5.0.0/debian/changelog	2026-05-06 19:13:17.000000000 +0000
@@ -1,3 +1,10 @@
+python3-lxc (1:5.0.0-2+deb13u1) trixie; urgency=medium
+
+  * Cherry-pick upstream fix for compatibility with Python 3.13+
+    (Closes: #1135733)
+
+ -- Mathias Gibbens <[email protected]>  Wed, 06 May 2026 19:13:17 +0000
+
 python3-lxc (1:5.0.0-2) unstable; urgency=medium
 
   * d/control:
diff -Nru python3-lxc-5.0.0/debian/gbp.conf python3-lxc-5.0.0/debian/gbp.conf
--- python3-lxc-5.0.0/debian/gbp.conf	2024-04-14 01:13:37.000000000 +0000
+++ python3-lxc-5.0.0/debian/gbp.conf	2026-05-06 19:13:11.000000000 +0000
@@ -1,3 +1,3 @@
 [DEFAULT]
 pristine-tar = True
-debian-branch = debian/unstable
+debian-branch = debian/trixie
diff -Nru python3-lxc-5.0.0/debian/patches/001-cherry-pick-python-313-fix.patch python3-lxc-5.0.0/debian/patches/001-cherry-pick-python-313-fix.patch
--- python3-lxc-5.0.0/debian/patches/001-cherry-pick-python-313-fix.patch	1970-01-01 00:00:00.000000000 +0000
+++ python3-lxc-5.0.0/debian/patches/001-cherry-pick-python-313-fix.patch	2026-05-06 19:13:13.000000000 +0000
@@ -0,0 +1,48 @@
+From 5c603a76658d7d278086682ad4481d4c792224f4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andreas=20V=C3=B6gele?= <[email protected]>
+Date: Tue, 13 May 2025 12:07:36 +0200
+Subject: [PATCH] Replace the deprecated PyOS_AfterFork() function
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Container_attach_and_possibly_wait() fails in Python 3.13 with
+"PyMutex_Unlock: unlocking mutex that is not locked" if PyOS_AfterFork()
+is used.
+
+Signed-off-by: Andreas Vögele <[email protected]>
+---
+ lxc.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/lxc.c b/lxc.c
+index b515acd..3039cfc 100644
+--- a/lxc.c
++++ b/lxc.c
+@@ -198,7 +198,11 @@ static int lxc_attach_python_exec(void* _payload)
+      * container. As lxc_attach() calls fork() PyOS_AfterFork should be called
+      * in the new process if the Python interpreter will continue to be used.
+      */
++#if PY_VERSION_HEX >= 0x030700F0
++    PyOS_AfterFork_Child();
++#else
+     PyOS_AfterFork();
++#endif
+ 
+     struct lxc_attach_python_payload *payload =
+         (struct lxc_attach_python_payload *)_payload;
+@@ -748,8 +752,14 @@ Container_attach_and_possibly_wait(Container *self, PyObject *args,
+     if (!options)
+         return NULL;
+ 
++#if PY_VERSION_HEX >= 0x030700F0
++    PyOS_BeforeFork();
++#endif
+     ret = self->container->attach(self->container, lxc_attach_python_exec,
+                                   &payload, options, &pid);
++#if PY_VERSION_HEX >= 0x030700F0
++    PyOS_AfterFork_Parent();
++#endif
+     if (ret < 0)
+         goto out;
+ 
diff -Nru python3-lxc-5.0.0/debian/patches/series python3-lxc-5.0.0/debian/patches/series
--- python3-lxc-5.0.0/debian/patches/series	1970-01-01 00:00:00.000000000 +0000
+++ python3-lxc-5.0.0/debian/patches/series	2026-05-06 19:13:13.000000000 +0000
@@ -0,0 +1 @@
+001-cherry-pick-python-313-fix.patch

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to