gh-120037: Disable user site packages when a ._pth file is used (GH-137428)

This commit is contained in:
Steve Dower 2025-08-19 21:28:28 +01:00 committed by GitHub
parent e39255e76d
commit 7d06a0af17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 19 additions and 0 deletions

View file

@ -804,6 +804,15 @@ def test_underpth_dll_file(self):
)], env=env)
self.assertTrue(rc, "sys.path is incorrect")
@support.requires_subprocess()
def test_underpth_no_user_site(self):
pth_lines = [test.support.STDLIB_DIR, 'import site']
exe_file = self._create_underpth_exe(pth_lines)
p = subprocess.run([exe_file, '-X', 'utf8', '-c',
'import sys; '
'sys.exit(not sys.flags.no_user_site)'])
self.assertEqual(p.returncode, 0, "sys.flags.no_user_site was 0")
class CommandLineTests(unittest.TestCase):
def exists(self, path):