From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 16 Oct 2025 10:31:59 +0000 (+0200) Subject: [3.14] gh-140170: Fix test_site with -s flag (GH-140179) (#140198) X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e69fb2008e288f57d95fde6f327b4c9bbdb5d878;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-140170: Fix test_site with -s flag (GH-140179) (#140198) gh-140170: Fix test_site with -s flag (GH-140179) Commit (cherry picked from commit 7ac94fcb1d09796f55faeaf30e349a86a88f7ed6) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index 39c451fbbbba..f8c6f37c607c 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -846,12 +846,15 @@ class CommandLineTests(unittest.TestCase): return 10, None 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: env["PYTHONUTF8"] = "1" 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') output = kill_python(proc)