File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -288,6 +288,7 @@ def _args_from_interpreter_flags():
288
288
'verbose' : 'v' ,
289
289
'bytes_warning' : 'b' ,
290
290
'quiet' : 'q' ,
291
+ 'safe_path' : 'P'
291
292
# -O is handled in _optim_args_from_interpreter_flags()
292
293
}
293
294
args = _optim_args_from_interpreter_flags ()
Original file line number Diff line number Diff line change @@ -884,6 +884,25 @@ def test_sys_flags_not_set(self):
884
884
PYTHONVERBOSE = "1" ,
885
885
)
886
886
887
+ # TODO: RUSTPYTHON
888
+ @unittest .expectedFailure
889
+ def test_pythonsafepath_env (self ):
890
+ # Test the PYTHONSAFEPATH environment variable
891
+ code = "import sys; print(sys.flags.safe_path)"
892
+ env = dict (os .environ )
893
+ env .pop ('PYTHONSAFEPATH' , None )
894
+ args = (sys .executable , '-P' , code )
895
+
896
+ proc = subprocess .run (args , stdout = subprocess .PIPE ,
897
+ universal_newlines = True , env = env )
898
+ self .assertEqual (proc .stdout .rstrip (), 'False' )
899
+ self .assertEqual (proc .returncode , 0 , proc )
900
+
901
+ env ['PYTHONSAFEPATH' ] = '1'
902
+ proc = subprocess .run (args , stdout = subprocess .PIPE ,
903
+ universal_newlines = True , env = env )
904
+ self .assertEqual (proc .stdout .rstrip (), 'True' )
905
+ self .assertEqual (proc .returncode , 0 , proc )
887
906
888
907
def test_main ():
889
908
support .run_unittest (CmdLineTest , IgnoreEnvironmentTest )
You can’t perform that action at this time.
0 commit comments