python-blockbuster: FTBFS building against python 3.15

Maximiliano Curia <[email protected]>
Newsgroups gmane.linux.debian.devel.python
Message-ID <[email protected]>
Package: src:python-blockbuster
Version: 1.5.26-2
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-blockbuster fails to build from source [1].

This is caused by a change in scandir, which now the iterator it
produces is immutable, so it can't be monkey patched.

I sent a pr with the patch upstream[2], and I'm attaching the version
that I sent to the sandbox so other packages that depend on
python-blockbuster can be rebuilt.

Please consider including this patch in your next upload.

Happy hacking,

[1]: https://debusine.debian.net/debian/r-python-python3.15/work-request/1066554/
[2]: https://github.com/cbornet/blockbuster/pull/71
-- 
"Can you imagine what I would do if I could do all I can?" -- Sun Tzu
Saludos /\/\ /\ >< `/
python3.15.patch (text/x-diff, 2 KB)
Description: Fix compatibility with Python 3.15
 In Python 3.15, posix.ScandirIterator has become an immutable type,
 causing setattr(type(scandir_it), '__next__', ...) to raise TypeError.
 .
 On Python 3.15+ (and Python < 3.9), fall back to hooking os.scandir directly
 on the os module instead of ScandirIterator.__next__.
Author: Maximiliano Curia <[email protected]>
Forwarded: no
--- a/blockbuster/blockbuster.py
+++ b/blockbuster/blockbuster.py
@@ -346,7 +346,9 @@
         excluded_modules=excluded_modules,
     )
 
-    if platform.python_implementation() != "CPython" or sys.version_info >= (3, 9):
+    if platform.python_implementation() != "CPython" or (
+        (3, 9) <= sys.version_info < (3, 15)
+    ):
         with os.scandir() as scandir_it:
             functions["os.scandir"] = BlockBusterFunction(
                 type(scandir_it),
@@ -354,6 +356,13 @@
                 scanned_modules=modules,
                 excluded_modules=excluded_modules,
             )
+    else:
+        functions["os.scandir"] = BlockBusterFunction(
+            None,
+            "os.scandir",
+            scanned_modules=modules,
+            excluded_modules=excluded_modules,
+        )
 
     for method in (
         "ismount",
--- a/tests/test_blockbuster.py
+++ b/tests/test_blockbuster.py
@@ -356,12 +356,15 @@
         os.listdir("/1")
 
 
[email protected](sys.version_info < (3, 9), reason="requires Python 3.9+")
 async def test_os_scandir() -> None:
-    with os.scandir(tempfile.tempdir) as files, pytest.raises(
-        BlockingError, match="Blocking call to ScandirIterator.__next__"
-    ):
-        next(files)
+    if (3, 9) <= sys.version_info < (3, 15):
+        with os.scandir(tempfile.tempdir) as files, pytest.raises(
+            BlockingError, match="Blocking call to ScandirIterator.__next__"
+        ):
+            next(files)
+    else:
+        with pytest.raises(BlockingError, match="Blocking call to os.scandir"):
+            os.scandir(tempfile.tempdir)
 
 
 async def test_os_access() -> None:
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.