Package: src:python-mitogen
Version: 0.3.50-1
User: [email protected]
Usertags: python3.15
Tags: patch, ftbfs, forky, sid

Hi!

While rebuilding the python related packages against the Python 3.15rc1
version we found that python-mitogen fails to build from source [1].
I found that the fix had already been done upstream with Commit 983c7fa
[2].

I applied the upstream fix in the sandbox [3] to be able to build the
packages that depend on python-mitogen, please consider applying the
patch to support the upcoming 3.15 version.

Happy hacking,

[1]: 
https://debusine.debian.net/debian/r-python-python3.15/artifact/4354507/raw/python-mitogen_0.3.50-1+py315.1_amd64-2026-08-18T05:48:15Z.build
[2]: 
https://github.com/mitogen-hq/mitogen/commit/983c7fa62aa32fa4a766b249534f59f08a3ef32f
[3]: https://debusine.debian.net/debian/r-python-python3.15/

--
"Can you imagine what I would do if I could do all I can?" -- Sun Tzu
Saludos /\/\ /\ >< `/
From: Alex Willmer <[email protected]>
Date: Wed, 26 Aug 2026 14:37:07 +0100
Subject: mitogen: Python3.15 support

This excludes Ansible + Python 3.15, because it requires Ansible 15 which has
not had any release yet.
---
 mitogen/imports/__init__.py |  4 +++-
 mitogen/imports/_py315.py   | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 mitogen/imports/_py315.py

diff --git a/mitogen/imports/__init__.py b/mitogen/imports/__init__.py
index bf246e26..e1e7afef 100644
--- a/mitogen/imports/__init__.py
+++ b/mitogen/imports/__init__.py
@@ -4,7 +4,9 @@
 
 import sys
 
-if sys.version_info >= (3, 14):
+if sys.version_info >= (3, 15):
+    from mitogen.imports._py315 import _code_imports
+elif sys.version_info >= (3, 14):
     from mitogen.imports._py314 import _code_imports
 elif sys.version_info >= (3, 6):
     from mitogen.imports._py36 import _code_imports
diff --git a/mitogen/imports/_py315.py b/mitogen/imports/_py315.py
new file mode 100644
index 00000000..7e4069f9
--- /dev/null
+++ b/mitogen/imports/_py315.py
@@ -0,0 +1,33 @@
+# SPDX-FileCopyrightText: 2026 Mitogen authors <https://github.com/mitogen-hq>
+# SPDX-License-Identifier: BSD-3-Clause
+# !mitogen: minify_safe
+
+import opcode
+
+IMPORT_NAME = opcode.opmap['IMPORT_NAME']
+LOAD_COMMON_CONSTANT = opcode.opmap['LOAD_COMMON_CONSTANT']
+LOAD_CONST = opcode.opmap['LOAD_CONST']
+LOAD_SMALL_INT = opcode.opmap['LOAD_SMALL_INT']
+
+
+def _code_imports(code, consts, names):
+    start = 4
+    while True:
+        op3_idx = code.find(IMPORT_NAME, start, -1)
+        if op3_idx < 0:
+            return
+        if op3_idx % 2:
+            start = op3_idx + 1
+            continue
+        if (
+            code[op3_idx-4] != LOAD_SMALL_INT
+            or (op2 := code[op3_idx-2]) not in {LOAD_COMMON_CONSTANT, 
LOAD_CONST}
+        ):
+            start = op3_idx + 2
+            continue
+        start = op3_idx + 6
+        arg1, arg2, arg3 = code[op3_idx-3], code[op3_idx-1], code[op3_idx+1]
+        if op2 == LOAD_COMMON_CONSTANT:
+            yield (arg1, names[arg3>>2], opcode._common_constants[arg2] or ())
+        elif op2 == LOAD_CONST:
+            yield (arg1, names[arg3>>2], consts[arg2] or ())

Reply via email to