Skip to content

DeprecationWarning: Module globals; __loader__ != __spec__.loader on 3.15 #2208

Description

@A5rocks

Describe the bug
When I use coverage, pytest, and traceback.print_stack() together, I get a deprecation warning on 3.15. I'm not convinced it's coverage's fault, but opening here first.

To Reproduce

x.py:

import traceback

traceback.print_stack()

Now run coverage run -m pytest x.py (after pip install coverage pytest). Note that the pytest part and the coverage part is necessary, if it's missing either things work correctly. You should see something like this:

a5rocks@whimsy /v/f/p/j/T/tmp.yE0qQYS20D> uv run coverage run -m pytest x.py
==================================== test session starts ====================================
platform darwin -- Python 3.15.0a6, pytest-9.1.1, pluggy-1.6.0
rootdir: /private/var/folders/py/j2lyj17j2sxg5xgjg2sxkx1h0000gn/T/tmp.yE0qQYS20D
collected 0 items

===================================== warnings summary ======================================
../../../../../../../Users/a5rocks/.local/share/uv/python/cpython-3.15.0a6-macos-aarch64-none/lib/python3.15/linecache.py:273
  /Users/a5rocks/.local/share/uv/python/cpython-3.15.0a6-macos-aarch64-none/lib/python3.15/linecache.py:273: DeprecationWarning: Module globals; __loader__ != __spec__.loader
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==================================== 1 warning in 0.00s =====================================

Answer the questions below:

  1. What version of Python are you using? 3.15.0a6
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful. 7.14.1
  3. What versions of what packages do you have installed? The output of pip freeze is helpful. pytest==9.0.3 also
  4. What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix. x.py above
  5. What commands should we run to reproduce the problem? Be specific. Include everything, even git clone, pip install, and so on. Explain like we're five! command given above.

Expected behavior
No deprecation warning.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions