Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-118234: Document Python subprocess requirement onSystemRoot env, add RuntimeWarning#134435

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jhohm wants to merge7 commits intopython:main
base:main
Choose a base branch
Loading
fromjhohm:gh-118234-2
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Fix tests to avoid and/or tolerate RuntimeWarning for missing SystemR…
…oot.
  • Loading branch information
@jhohm
jhohm committedMay 21, 2025
commit9c0ce134eae3a2e78dfe7bd51a1aec09a66fde93
5 changes: 4 additions & 1 deletionLib/test/test_launcher.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -287,7 +287,10 @@ def fake_venv(self):
venv_exe = (venv / ("python_d.exe" if DEBUG_BUILD else "python.exe"))
venv_exe.touch()
try:
yield venv_exe, {"VIRTUAL_ENV": str(venv.parent)}
yield venv_exe, {
"SystemRoot": os.environ.get("SystemRoot"),
"VIRTUAL_ENV": str(venv.parent),
}
finally:
shutil.rmtree(venv)

Expand Down
21 changes: 12 additions & 9 deletionsLib/test/test_subprocess.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -857,13 +857,14 @@ def test_one_environment_variable(self):
'sys.stdout.write("fruit="+os.getenv("fruit"))']
if sys.platform == "win32":
cmd = ["CMD", "/c", "SET", "fruit"]
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=newenv) as p:
stdout, stderr = p.communicate()
if p.returncode and support.verbose:
print("STDOUT:", stdout.decode("ascii", "replace"))
print("STDERR:", stderr.decode("ascii", "replace"))
self.assertEqual(p.returncode, 0)
self.assertEqual(stdout.strip(), b"fruit=orange")
with warnings_helper.check_warnings(('env.*SystemRoot', RuntimeWarning), quiet=True):
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=newenv) as p:
stdout, stderr = p.communicate()
if p.returncode and support.verbose:
print("STDOUT:", stdout.decode("ascii", "replace"))
print("STDERR:", stderr.decode("ascii", "replace"))
self.assertEqual(p.returncode, 0)
self.assertEqual(stdout.strip(), b"fruit=orange")

def test_invalid_cmd(self):
# null character in the command name
Expand DownExpand Up@@ -1764,7 +1765,8 @@ def test_run_with_an_empty_env(self):
args = [sys.executable, "-c", 'pass']
# Ignore subprocess errors - we only care that the API doesn't
# raise an OSError
subprocess.run(args, env={})
with warnings_helper.check_warnings(('env.*SystemRoot', RuntimeWarning), quiet=True):
subprocess.run(args, env={})

def test_capture_output(self):
cp = self.run_python(("import sys;"
Expand DownExpand Up@@ -3567,7 +3569,8 @@ def test_issue31471(self):
class BadEnv(dict):
keys = None
with self.assertRaises(TypeError):
subprocess.Popen(ZERO_RETURN_CMD, env=BadEnv())
with warnings_helper.check_warnings(('env.*SystemRoot', RuntimeWarning), quiet=True):
subprocess.Popen(ZERO_RETURN_CMD, env=BadEnv())

def test_close_fds(self):
# close file descriptors
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp