Skip to content

Coverage 7.8.0 fails on 3.11.0-alpha.7 ("'sys.flags' object has no attribute 'safe_path'") #1946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SylvainDe opened this issue Mar 31, 2025 · 3 comments
Labels
bug Something isn't working fixed

Comments

@SylvainDe
Copy link

SylvainDe commented Mar 31, 2025

Describe the bug

Very minor issue

On coverage 7.8.0, an exception is raised on Python 3.11.0-alpha.7 .
Coverage-7.7.1 is working fine with Python 3.11.0-alpha.7 .
Coverage 7.8.0 is working fine with Python 3.11.0-beta.1.

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.0-alpha.7/x64/bin/coverage", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.0-alpha.7/x64/lib/python3.11/site-packages/coverage/cmdline.py", line 970, in main
    status = CoverageScript().command_line(argv)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.0-alpha.7/x64/lib/python3.11/site-packages/coverage/cmdline.py", line 681, in command_line
    return self.do_run(options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.0-alpha.7/x64/lib/python3.11/site-packages/coverage/cmdline.py", line 849, in do_run
    runner.prepare()
    ^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.0-alpha.7/x64/lib/python3.11/site-packages/coverage/execfile.py", line 93, in prepare
    if env.PYVERSION >= (3, 11) and getattr(sys.flags, "safe_path"):
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'sys.flags' object has no attribute 'safe_path'

To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:

  1. What version of Python are you using? 3.11.0-alpha.7
  2. What version of coverage.py shows the problem? The output of coverage debug sys is helpful.
  3. What versions of what packages do you have installed? The output of pip freeze is helpful.
  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.
  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!

Expected behavior
No exception is raised.

Additional context

https://github.com/SylvainDe/DidYouMean-Python/actions/runs/14154716087/job/39652462260

Pre-analysis

The access to the safe_path attribute was added with 32e8d79 .

It is currently controlled by a check of the Python version env.PYVERSION >= (3, 11). The fix would probably be to make it slightly more precise.

@SylvainDe SylvainDe added the bug Something isn't working label Mar 31, 2025
@nedbat
Copy link
Owner

nedbat commented Mar 31, 2025

We can change the condition to be more precise. But I'm curious why you are using 3.11.0a7?

@nedbat
Copy link
Owner

nedbat commented Mar 31, 2025

Fixed in commit 7e3acd9.

@nedbat nedbat closed this as completed Mar 31, 2025
@nedbat nedbat added the fixed label Mar 31, 2025
@SylvainDe
Copy link
Author

We can change the condition to be more precise. But I'm curious why you are using 3.11.0a7?

Tbh, I do not have any good reason and I should definitly get rid of it in my github workflow config.

Anyway, thanks for your fix and for for the coverage maintenance in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants