diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cde56d34..906c068c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13', '3.14.0-rc.2', pypy3.11] + python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13', '3.14', '3.15.0-alpha.3', pypy3.11] fail-fast: false # Steps represent a sequence of tasks that will be executed as part of the job steps: diff --git a/fail2ban/server/utils.py b/fail2ban/server/utils.py index 02a6bc6d..133add24 100644 --- a/fail2ban/server/utils.py +++ b/fail2ban/server/utils.py @@ -29,6 +29,7 @@ import subprocess import sys from threading import Lock import time +import types from ..helpers import getLogger, _merge_dicts, uni_decode from collections import OrderedDict @@ -352,6 +353,7 @@ class Utils(): def load_python_module(pythonModule): pythonModuleName = os.path.splitext( os.path.basename(pythonModule))[0] - mod = importlib.machinery.SourceFileLoader( - pythonModuleName, pythonModule).load_module() + ldr = importlib.machinery.SourceFileLoader(pythonModuleName, pythonModule) + mod = types.ModuleType(ldr.name) + ldr.exec_module(mod) return mod diff --git a/fail2ban/tests/action_d/test_smtp.py b/fail2ban/tests/action_d/test_smtp.py index a6904255..6e4b926d 100644 --- a/fail2ban/tests/action_d/test_smtp.py +++ b/fail2ban/tests/action_d/test_smtp.py @@ -22,6 +22,7 @@ import threading import unittest import re import sys +import types import importlib from ..dummyjail import DummyJail @@ -296,10 +297,11 @@ try: self.jail = DummyJail() pythonModule = os.path.join(CONFIG_DIR, "action.d", "smtp.py") pythonModuleName = os.path.basename(pythonModule.rstrip(".py")) - customActionModule = importlib.machinery.SourceFileLoader( - pythonModuleName, pythonModule).load_module() + ldr = importlib.machinery.SourceFileLoader(pythonModuleName, pythonModule) + mod = types.ModuleType(ldr.name) + ldr.exec_module(mod) - self.action = customActionModule.Action( + self.action = mod.Action( self.jail, "test", host="localhost:%i" % self.port) self.action.ssl = True