python-typeguard: FTBFS building against python 3.15

Maximiliano Curia <[email protected]>
Newsgroups gmane.linux.debian.devel.python
Message-ID <[email protected]>
Package: src:python-typeguard
Version: 4.4.4-3
User: [email protected]
Usertags: python3.15
Tags: patch

Hi!

While rebuilding the python related packages against the python version
3.15rc1 we found that python-typeguard fails to build from source[1].

The compatibility support for python 3.15 was added in the release 4.6.0
of python-typeguard, I'm attaching a backported version of the patch
that addes the compatibility support.

Please consider including this patch in your next upload or updating the
package to the new upstream releas.

Happy hacking,

[1]: https://debusine.debian.net/debian/r-python-python3.15/work-request/1081155/
-- 
"Can you imagine what I would do if I could do all I can?" -- Sun Tzu
Saludos /\/\ /\ >< `/
fixed_compatibility_with_py315.patch (text/x-diff, 3.3 KB)
commit 2e63076a7bbdee0558f3a03f5a66e9f83b4e2241
Author: Tomáš Hrnčiar <[email protected]>
Date:   Sat May 23 13:04:39 2026 +0200

    Fixed compatibility with Python 3.15 (#554)

Index: python-typeguard/src/typeguard/_importhook.py
===================================================================
--- python-typeguard.orig/src/typeguard/_importhook.py
+++ python-typeguard/src/typeguard/_importhook.py
@@ -47,8 +47,8 @@ def _call_with_frames_removed(
     return f(*args, **kwargs)
 
 
-def optimized_cache_from_source(path: str, debug_override: bool | None = None) -> str:
-    return cache_from_source(path, debug_override, optimization=OPTIMIZATION)
+def optimized_cache_from_source(path: str) -> str:
+    return cache_from_source(path, optimization=OPTIMIZATION)
 
 
 class TypeguardLoader(SourceFileLoader):
@@ -56,6 +56,7 @@ class TypeguardLoader(SourceFileLoader):
     def source_to_code(
         data: Buffer | str | ast.Module | ast.Expression | ast.Interactive,
         path: Buffer | str | PathLike[str] = "<string>",
+        fullname: str | None = None,
     ) -> CodeType:
         if isinstance(data, (ast.Module, ast.Expression, ast.Interactive)):
             tree = data
@@ -65,12 +66,21 @@ class TypeguardLoader(SourceFileLoader):
             else:
                 source = decode_source(data)
 
-            tree = _call_with_frames_removed(
-                ast.parse,
-                source,
-                path,
-                "exec",
-            )
+            if sys.version_info >= (3, 15):
+                tree = _call_with_frames_removed(
+                    ast.parse,
+                    source,
+                    path,
+                    "exec",
+                    module=fullname,
+                )
+            else:
+                tree = _call_with_frames_removed(
+                    ast.parse,
+                    source,
+                    path,
+                    "exec",
+                )
 
         tree = TypeguardTransformer().visit(tree)
         ast.fix_missing_locations(tree)
@@ -84,9 +94,14 @@ class TypeguardLoader(SourceFileLoader):
             print(ast.unparse(tree), file=sys.stderr)
             print("----------------------------------------------", file=sys.stderr)
 
-        return _call_with_frames_removed(
-            compile, tree, path, "exec", 0, dont_inherit=True
-        )
+        if sys.version_info >= (3, 15):
+            return _call_with_frames_removed(
+                compile, tree, path, "exec", 0, dont_inherit=True, module=fullname
+            )
+        else:
+            return _call_with_frames_removed(
+                compile, tree, path, "exec", 0, dont_inherit=True
+            )
 
     def exec_module(self, module: ModuleType) -> None:
         # Use a custom optimization marker – the import lock should make this monkey
Index: python-typeguard/tests/dummymodule.py
===================================================================
--- python-typeguard.orig/tests/dummymodule.py
+++ python-typeguard/tests/dummymodule.py
@@ -17,7 +17,6 @@ from typing import (
     TypeVar,
     Union,
     no_type_check,
-    no_type_check_decorator,
     overload,
 )
 
@@ -41,6 +40,7 @@ P = ParamSpec("P")
 
 
 if sys.version_info <= (3, 13):
+    from typing import no_type_check_decorator
 
     @no_type_check_decorator
     def dummy_decorator(func):
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.