From 6b0455e7c3d2e733d744cc86d88cb96ffed4f16c Mon Sep 17 00:00:00 2001 From: Christopher Lott <10234212+chrisinmtown@users.noreply.github.com> Date: Fri, 7 Nov 2025 08:39:41 -0500 Subject: [PATCH] Migrate to importlib.util.find_spec for Python 3.14 compatibility Migrate `aiohttp_app.py` away from `pkgutil.get_loader()` which was deprecated in Python 3.12 and removed in Python 3.14. --- connexion/apps/aiohttp_app.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/connexion/apps/aiohttp_app.py b/connexion/apps/aiohttp_app.py index 244b22b44..99e472130 100644 --- a/connexion/apps/aiohttp_app.py +++ b/connexion/apps/aiohttp_app.py @@ -2,9 +2,9 @@ This module defines an AioHttpApp, a Connexion application to wrap an AioHttp application. """ +import importlib.util import logging import pathlib -import pkgutil import sys from aiohttp import web @@ -30,11 +30,11 @@ def get_root_path(self): if mod is not None and hasattr(mod, "__file__"): return pathlib.Path(mod.__file__).resolve().parent - loader = pkgutil.get_loader(self.import_name) + spec = importlib.util.find_spec(self.import_name) filepath = None - if hasattr(loader, "get_filename"): - filepath = loader.get_filename(self.import_name) + if hasattr(spec, "loader") and hasattr(spec.loader, "get_filename"): + filepath = spec.loader.get_filename(self.import_name) if filepath is None: raise RuntimeError(f"Invalid import name '{self.import_name}'")