gh-140170: Fix test_site with -s flag (GH-140179)

Commit
This commit is contained in:
Stan Ulbrych 2025-10-16 10:49:08 +01:00 committed by GitHub
parent 2a2bc82cef
commit 7ac94fcb1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -855,12 +855,15 @@ def get_excepted_output(self, *args):
return 10, None return 10, None
def invoke_command_line(self, *args): def invoke_command_line(self, *args):
args = ["-m", "site", *args] cmd_args = []
if sys.flags.no_user_site:
cmd_args.append("-s")
cmd_args.extend(["-m", "site", *args])
with EnvironmentVarGuard() as env: with EnvironmentVarGuard() as env:
env["PYTHONUTF8"] = "1" env["PYTHONUTF8"] = "1"
env["PYTHONIOENCODING"] = "utf-8" env["PYTHONIOENCODING"] = "utf-8"
proc = spawn_python(*args, text=True, env=env, proc = spawn_python(*cmd_args, text=True, env=env,
encoding='utf-8', errors='replace') encoding='utf-8', errors='replace')
output = kill_python(proc) output = kill_python(proc)