| 1 |
# From https://github.com/CheetahTemplate3/cheetah3/pull/73 |
| 2 |
commit f935b58cdf47570b288e59a8a19e157d5909f7ac |
| 3 |
Author: Steve Kowalik <[email protected]> |
| 4 |
Date: Fri Jul 17 15:07:49 2026 +1000 |
| 5 |
|
| 6 |
Stop using load_module() in compat |
| 7 |
|
| 8 |
load_module() has been deprecated effectively since it was added, |
| 9 |
replaced by exec_module in Python 3.5, switch to using that, since |
| 10 |
load_module() was removed in Python 3.15. |
| 11 |
|
| 12 |
Note this effectively removes support for Python 3.4, but I can reenable |
| 13 |
that if you prefer. |
| 14 |
|
| 15 |
diff --git a/Cheetah/compat.py b/Cheetah/compat.py |
| 16 |
index 78cfcdd..7810506 100644 |
| 17 |
--- a/Cheetah/compat.py |
| 18 |
+++ b/Cheetah/compat.py |
| 19 |
@@ -53,7 +53,9 @@ else: |
| 20 |
|
| 21 |
def load_module_from_file(base_name, module_name, filename): |
| 22 |
specs = importlib.util.spec_from_file_location(module_name, filename) |
| 23 |
- return specs.loader.load_module() |
| 24 |
+ module = importlib.util.module_from_spec(specs) |
| 25 |
+ specs.loader.exec_module(module) |
| 26 |
+ return module |
| 27 |
|
| 28 |
new_module = types.ModuleType |
| 29 |
|