summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_support.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-05-05 23:34:11 (GMT)
committerGitHub <noreply@github.com>2022-05-05 23:34:11 (GMT)
commitada8b6d1b1b02ae7c38f161c2a0ad866559fe18b (patch)
tree2da5c4813d3cf360a121a49268aa9fd2c9fe3cbb /Lib/test/test_support.py
parentf6dd14c65336cda4e2ebccbc6408dfe3b0a68a34 (diff)
downloadcpython-ada8b6d1b1b02ae7c38f161c2a0ad866559fe18b.zip
cpython-ada8b6d1b1b02ae7c38f161c2a0ad866559fe18b.tar.gz
cpython-ada8b6d1b1b02ae7c38f161c2a0ad866559fe18b.tar.bz2
gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)
Add the -P command line option and the PYTHONSAFEPATH environment variable to not prepend a potentially unsafe path to sys.path. * Add sys.flags.safe_path flag. * Add PyConfig.safe_path member. * Programs/_bootstrap_python.c uses config.safe_path=0. * Update subprocess._optim_args_from_interpreter_flags() to handle the -P command line option. * Modules/getpath.py sets safe_path to 1 if a "._pth" file is present.
Diffstat (limited to 'Lib/test/test_support.py')
-rw-r--r--Lib/test/test_support.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 90e971d..dce4980 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -522,6 +522,7 @@ class TestSupport(unittest.TestCase):
['-E'],
['-v'],
['-b'],
+ ['-P'],
['-q'],
['-I'],
# same option multiple times
@@ -541,7 +542,8 @@ class TestSupport(unittest.TestCase):
with self.subTest(opts=opts):
self.check_options(opts, 'args_from_interpreter_flags')
- self.check_options(['-I', '-E', '-s'], 'args_from_interpreter_flags',
+ self.check_options(['-I', '-E', '-s', '-P'],
+ 'args_from_interpreter_flags',
['-I'])
def test_optim_args_from_interpreter_flags(self):