On 2025/01/06 10:39, Stuart Henderson wrote:
> thanks, will take a look.
>
> On 2025/01/06 10:33, Laurence Tratt wrote:
> > After an upgrade to the latest snapshot packages, quodlibet fails with:
[..]
Found a few upstream commits to fix this. Here's a minimal diff
(I'll commit with bump + some other bits relating to tests).
Index: patches/patch-quodlibet__import_py
===================================================================
RCS file: patches/patch-quodlibet__import_py
diff -N patches/patch-quodlibet__import_py
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-quodlibet__import_py 6 Jan 2025 10:51:59 -0000
@@ -0,0 +1,29 @@
+From a8b6f6bb34864a6821174edbf7802b689e440db3 Mon Sep 17 00:00:00 2001
+From: LuK1337 <priv.luk@gmail.com>
+Date: Wed, 23 Aug 2023 17:13:23 +0200
+Subject: [PATCH] Fix startup on Python 3.12
+
+Index: quodlibet/_import.py
+--- quodlibet/_import.py.orig
++++ quodlibet/_import.py
+@@ -7,7 +7,7 @@
+ # (at your option) any later version.
+
+ import sys
+-import importlib
++import importlib.util
+
+
+ class RedirectImportHook:
+@@ -30,6 +30,11 @@ class RedirectImportHook:
+
+ self._name = name
+ self._packages = packages
++
++ def find_spec(self, fullname, path, target=None):
++ loader = self.find_module(fullname, path)
++ if loader is not None:
++ return importlib.util.spec_from_loader(fullname, loader)
+
+ def find_module(self, fullname, path=None):
+ package = fullname.split(".")[0]
Index: patches/patch-quodlibet_util___init___py
===================================================================
RCS file: /cvs/ports/audio/quodlibet/patches/patch-quodlibet_util___init___py,v
diff -u -p -r1.6 patch-quodlibet_util___init___py
--- patches/patch-quodlibet_util___init___py 29 Aug 2023 21:25:53 -0000 1.6
+++ patches/patch-quodlibet_util___init___py 6 Jan 2025 10:51:59 -0000
@@ -1,3 +1,14 @@
+load_library hunks:
+
+From 7fda4345bdabafa896f4a632990c20d91076e98d Mon Sep 17 00:00:00 2001
+From: Christoph Reiter <reiter.christoph@gmail.com>
+Date: Sun, 27 Aug 2023 19:48:28 +0200
+Subject: [PATCH] load_library: handle AttributeError as well
+
+Looks like with Python 3.12 getattr on cdll now correctly raises
+AttributeError instead of OSError, so catch that too.
+This fixes the tests in case libxine is missing.
+
Index: quodlibet/util/__init__.py
--- quodlibet/util/__init__.py.orig
+++ quodlibet/util/__init__.py
@@ -18,3 +29,12 @@ Index: quodlibet/util/__init__.py
NamedTemporaryFile, is_flatpak, cmp, matches_flatpak_runtime
+@@ -961,7 +961,7 @@ def load_library(names, shared=True):
+
+ try:
+ return load_func(dlopen_name), name
+- except OSError as e:
++ except (OSError, AttributeError) as e:
+ errors.append(str(e))
+
+ raise OSError("\n".join(errors))
Index: patches/patch-quodlibet_util_config_py
===================================================================
RCS file: patches/patch-quodlibet_util_config_py
diff -N patches/patch-quodlibet_util_config_py
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-quodlibet_util_config_py 6 Jan 2025 10:51:59 -0000
@@ -0,0 +1,17 @@
+From a8b6f6bb34864a6821174edbf7802b689e440db3 Mon Sep 17 00:00:00 2001
+From: LuK1337 <priv.luk@gmail.com>
+Date: Wed, 23 Aug 2023 17:13:23 +0200
+Subject: [PATCH] Fix startup on Python 3.12
+
+Index: quodlibet/util/config.py
+--- quodlibet/util/config.py.orig
++++ quodlibet/util/config.py
+@@ -377,7 +377,7 @@ class Config:
+ with open(filename, "rb") as fileobj:
+ fileobj = StringIO(
+ fileobj.read().decode("utf-8", "surrogateescape"))
+- self._config.readfp(fileobj, filename)
++ self._config.read_file(fileobj, filename)
+ except (IOError, OSError):
+ return
+
Index: patches/patch-quodlibet_util_importhelper_py
===================================================================
RCS file: patches/patch-quodlibet_util_importhelper_py
diff -N patches/patch-quodlibet_util_importhelper_py
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-quodlibet_util_importhelper_py 6 Jan 2025 10:51:59 -0000
@@ -0,0 +1,28 @@
+From a8b6f6bb34864a6821174edbf7802b689e440db3 Mon Sep 17 00:00:00 2001
+From: LuK1337 <priv.luk@gmail.com>
+Date: Wed, 23 Aug 2023 17:13:23 +0200
+Subject: [PATCH] Fix startup on Python 3.12
+
+Index: quodlibet/util/importhelper.py
+--- quodlibet/util/importhelper.py.orig
++++ quodlibet/util/importhelper.py
+@@ -92,8 +92,8 @@ def load_module(name, package, path):
+ except KeyError:
+ pass
+
+- loader = importlib.find_loader(fullname, [path])
+- if loader is None:
++ spec = importlib.machinery.PathFinder.find_spec(fullname, [path])
++ if spec is None:
+ return
+
+ # modules need a parent package
+@@ -101,7 +101,7 @@ def load_module(name, package, path):
+ spec = importlib.machinery.ModuleSpec(package, None, is_package=True)
+ sys.modules[package] = importlib.util.module_from_spec(spec)
+
+- mod = loader.load_module(fullname)
++ mod = spec.loader.load_module(fullname)
+
+ # make it accessible from the parent, like __import__ does
+ vars(sys.modules[package])[name] = mod
No comments:
Post a Comment