We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 62d09b4 commit 16218cfCopy full SHA for 16218cf
Lib/subprocess.py
@@ -309,6 +309,7 @@ def _args_from_interpreter_flags():
309
'verbose': 'v',
310
'bytes_warning': 'b',
311
'quiet': 'q',
312
+ 'safe_path': 'P'
313
# -O is handled in _optim_args_from_interpreter_flags()
314
}
315
args = _optim_args_from_interpreter_flags()
Lib/test/test_cmd_line.py
@@ -1008,6 +1008,25 @@ def test_sys_flags_not_set(self):
1008
PYTHONSAFEPATH="1",
1009
)
1010
1011
+ # TODO: RUSTPYTHON
1012
+ @unittest.expectedFailure
1013
+ def test_pythonsafepath_env(self):
1014
+ # Test the PYTHONSAFEPATH environment variable
1015
+ code = "import sys; print(sys.flags.safe_path)"
1016
+ env = dict(os.environ)
1017
+ env.pop('PYTHONSAFEPATH', None)
1018
+ args = (sys.executable, '-P', code)
1019
+
1020
+ proc = subprocess.run(args, stdout=subprocess.PIPE,
1021
+ universal_newlines=True, env=env)
1022
+ self.assertEqual(proc.stdout.rstrip(), 'False')
1023
+ self.assertEqual(proc.returncode, 0, proc)
1024
1025
+ env['PYTHONSAFEPATH'] = '1'
1026
1027
1028
+ self.assertEqual(proc.stdout.rstrip(), 'True')
1029
1030
1031
class SyntaxErrorTests(unittest.TestCase):
1032
def check_string(self, code):
0 commit comments