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 /\/\ /\ >< `/
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:

Reply via email to