Skip to content

pkgutil.find_loader deprecation warning attributed to incorrect module when calling pkgutil.get_loader #132605

Open
@amblina

Description

@amblina

Bug report

Bug description:

Given the following warnings configuration in pyproject.toml:

filterwarnings = [
    '''ignore:.*pkgutil\.find_loader.*:DeprecationWarning:gi''',
    '''ignore:.*pkgutil\.get_loader.*:DeprecationWarning:gi''',
]

I still get the following traceback:

    from gi.repository import GLib
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:921: in _load_unlocked
    ???
<frozen importlib._bootstrap>:813: in module_from_spec
    ???
/var/lib/<redacted>/.venv/lib/python3.13/site-packages/gi/importer.py:147: in create_module
    dynamic_module = load_overrides(introspection_module)
/var/lib/<redacted>/.venv/lib/python3.13/site-packages/gi/overrides/__init__.py:108: in load_overrides
    override_loader = get_loader(override_package_name)
/opt/ont/python/lib/python3.13/pkgutil.py:291: in get_loader
    return find_loader(fullname)
/opt/ont/python/lib/python3.13/pkgutil.py:301: in find_loader
    warnings._deprecated("pkgutil.find_loader",
/opt/ont/python/lib/python3.13/warnings.py:669: in _deprecated
    warn(msg, DeprecationWarning, stacklevel=3)
E   DeprecationWarning: 'pkgutil.find_loader' is deprecated and slated for removal in Python 3.14; use importlib.util.find_spec() instead

Removing :gi and replacing with :pkgutil in toml ignores the warning as specified however, the library that is calling pkgutil is gi not pkgutil. This causes misattribution and these issues are more likely to result in people ignoring warnings in general.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedstdlibPython modules in the Lib dirtopic-importlibtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions