| 1 |
Description: Replace load_module |
| 2 |
The load_module method was deprecated in Python 3.4 and was removed in |
| 3 |
Python 3.15. |
| 4 |
Author: Takashi Kajinami <[email protected]> |
| 5 |
Origin: upstream, https://github.com/pecan/pecan/pull/173 |
| 6 |
Bug-Debian: https://bugs.debian.org/1147120 |
| 7 |
Forwarded: not-needed |
| 8 |
Last-Update: 2026-09-17 |
| 9 |
Assisted-By: Infomaniak Euria-Code |
| 10 |
|
| 11 |
Index: python-pecan/pecan/configuration.py |
| 12 |
=================================================================== |
| 13 |
--- python-pecan.orig/pecan/configuration.py |
| 14 |
+++ python-pecan/pecan/configuration.py |
| 15 |
@@ -3,6 +3,7 @@ import inspect |
| 16 |
import os |
| 17 |
import sys |
| 18 |
from importlib.machinery import SourceFileLoader |
| 19 |
+from importlib.util import (module_from_spec, spec_from_loader) |
| 20 |
|
| 21 |
|
| 22 |
IDENTIFIER = re.compile(r'[a-z_](\w)*$', re.IGNORECASE) |
| 23 |
@@ -169,7 +170,11 @@ def conf_from_file(filepath): |
| 24 |
# This provides more verbose import-related error reporting than exec() |
| 25 |
absname, _ = os.path.splitext(abspath) |
| 26 |
basepath, module_name = absname.rsplit(os.sep, 1) |
| 27 |
- SourceFileLoader(module_name, abspath).load_module(module_name) |
| 28 |
+ loader = SourceFileLoader(module_name, abspath) |
| 29 |
+ spec = spec_from_loader(module_name, loader) |
| 30 |
+ module = module_from_spec(spec) |
| 31 |
+ |
| 32 |
+ spec.loader.exec_module(module) |
| 33 |
|
| 34 |
# If we were able to import as a module, actually exec the compiled code |
| 35 |
exec(compiled, globals(), conf_dict) |