Bug 2327965 - python-flask fails to build with Python 3.14: AttributeError: module 'pkgutil' has no attribute 'get_loader'
Summary: python-flask fails to build with Python 3.14: AttributeError: module 'pkgutil...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-flask
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Karolina Surma
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.14
TreeView+ depends on / blocked
 
Reported: 2024-11-22 09:02 UTC by Karolina Surma
Modified: 2025-05-29 09:10 UTC (History)
10 users (show)

Fixed In Version: python-flask-3.1.1-1.fc43
Clone Of:
Environment:
Last Closed: 2025-05-29 09:10:29 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github pallets flask issues 5692 0 None open 'pkgutil.get_loader' is removed from Python 3.14 2025-03-19 11:11:15 UTC

Description Karolina Surma 2024-11-22 09:02:32 UTC
python-flask fails to build with Python 3.14.0a1.

_____________ ERROR at setup of test_installed_module_paths[True] ______________

request = <SubRequest 'limit_loader' for <Function test_installed_module_paths[True]>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f1fe6bc77e0>

    @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'

tests/conftest.py:122: AttributeError
_____________ ERROR at setup of test_installed_package_paths[True] _____________

request = <SubRequest 'limit_loader' for <Function test_installed_package_paths[True]>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f1fe6bc7e70>

    @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'

tests/conftest.py:122: AttributeError
______________ 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'


According to https://docs.python.org/dev/whatsnew/3.14.html#multiprocessing

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.)


https://docs.python.org/3.14/whatsnew/3.14.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14/fedora-rawhide-x86_64/08300617-python-flask/

For all our attempts to build python-flask with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/python-flask/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.14:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Aoife Moloney 2025-02-26 13:17:18 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 42 development cycle.
Changing version to 42.


Note You need to log in before you can comment on or make changes to this bug.