⚡ Solution Summary

  • Tests using pkgutil.get_loader should be removed
  • The search code now uses importlib
  • Ensure compatibility with Python 3.14
  • Review test cases for relevance.
Per What's new in Python 3.14: > Remove deprecated pkgutil.get_loader() and pkgutil.find_loader(). These had previously raised a DeprecationWarning since Python 3.12. (Contributed by Bénédikt Tran in gh-97850.) It manifests in flask's tests: ``` ______________ ERROR at setup of test_prefix_package_paths[True] _______________ request = <SubRequest 'limit_loader' for <Function test_prefix_package_paths[True]>> monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f1fe6cb9b70> @pytest.fixture(params=(True, False)) def limit_loader(request, monkeypatch): """Patch pkgutil.get_loader to give loader without get_filename or archive. This provides for tests where a system has custom loaders, e.g. Google App Engine's HardenedModulesHook, which have neither the `get_filename` method nor the `archive` attribute. This fixture will run the testcase twice, once with and once without the limitation/mock. """ if not request.param: return class LimitedLoader: def __init__(self, loader): self.loader = loader def __getattr__(self, name): if name in {"archive", "get_filename"}: raise AttributeError(f"Mocking a loader which does not have {name!r}.") return getattr(self.loader, name) > old_get_loader = pkgutil.get_loader E AttributeError: module 'pkgutil' has no attribute 'get_loader' ERROR tests/test_instance_config.py::test_installed_module_paths[True] - Attr... ERROR tests/test_instance_config.py::test_installed_package_paths[True] - Att... ERROR tests/test_instance_config.py::test_prefix_package_paths[True] - Attrib... ``` Run the tests with Python 3.14 Environment: - Python version: 3.14.0a6 - Flask version: 3.1.0

Discussion & Fixes

CheeseCake87 2025-03-19
Is there a specific reason why you need to use an alpha build of Python? Also, see: https://peps.python.org/pep-0745/ https://palletsprojects.com/releases
CheeseCake87 2025-03-19
Sorry, I see now that you are bringing it to attention. Apologise.
befeleme 2025-03-19
I should have been more verbose in justification. Yes, my intention is to make you aware of the issue coming soon - there will only be one more alpha release in ~month. In Fedora, we're testing from the 1st alpha of a new Python release, to make sure the ecosystem is gradually ready from the day of release.
davidism 2025-03-29
I'm pretty sure these tests can be removed. The search code being tested was changed to use `importlib` a long time ago, does not access `archive`, and tests access to `get_filename` but handles it missing.