1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-13 19:29:53 +03:00
aports/community/py3-pecan/ext.patch

31 lines
952 B
Diff

From 437dd10b8d77ec7f8a86194274e7b29b09c5e48f Mon Sep 17 00:00:00 2001
From: Ryan Petrello <ryan@ryanpetrello.com>
Date: Tue, 21 Jan 2025 18:54:48 -0500
Subject: [PATCH] support pecan.ext in python >= 3.12
see: https://github.com/pecan/pecan/issues/157
diff --git a/pecan/extensions.py b/pecan/extensions.py
index 87b9925..aff7727 100644
--- a/pecan/extensions.py
+++ b/pecan/extensions.py
@@ -10,7 +10,18 @@ class PecanExtensionMissing(ImportError):
pass
-class PecanExtensionImporter(object):
+#
+# support for importlib.findloader and importlib.find_module
+# were removed in Python 3.12
+# see: https://docs.python.org/3/whatsnew/3.12.html#importlib
+#
+class FindLoaderPy312Mixin:
+
+ def find_spec(self, fullname, path, target=None):
+ return self.load_module(fullname)
+
+
+class PecanExtensionImporter(FindLoaderPy312Mixin if sys.version_info >= (3, 12) else object):
"""
Short circuits imports for extensions.