Skip to content

Commit

Permalink
changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep authored and nedbat committed Nov 18, 2023
1 parent f682a3f commit 28a62e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion coverage/execfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def prepare(self) -> None:
This needs to happen before any importing, and without importing anything.
"""
path0: Optional[str]
if os.environ.get('PYTHONSAFEPATH', ''):
if env.PYVERSION >= (3, 11) and os.environ.get('PYTHONSAFEPATH', ''):
# See https://docs.python.org/3/using/cmdline.html#cmdoption-P
path0 = None
elif self.as_module:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_execfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import py_compile
import re
import sys
from unittest import mock
from pathlib import Path
from typing import Any, Iterator

import pytest
Expand Down Expand Up @@ -307,9 +307,9 @@ def test_pkg1_init(self) -> None:
assert out == "pkg1.__init__: pkg1\npkg1.__init__: __main__\n"
assert err == ""

def test_pythonpath(self, tmp_path) -> None:
env = {"PYTHONSAFEPATH": "1"}
with mock.patch.dict(os.environ, env), change_dir(tmp_path):
def test_pythonpath(self, tmp_path: Path) -> None:
self.set_environ("PYTHONSAFEPATH", "1")
with change_dir(tmp_path):
run_python_module(["process_test.try_execfile"])
out, err = self.stdouterr()
mod_globs = json.loads(out)
Expand Down

0 comments on commit 28a62e7

Please sign in to comment.