Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

Thanks Victor for the details. 

> In the C code, sys.flags.isolated clearly documented as linked to the -I 
> option:

With respect to documentation I was talking about '-I' not being documented in 
the table at https://docs.python.org/3.7/library/sys.html#sys.flags though it's 
present in the C code and in sys.flags.isolated.

> -I is different from -s -E: it also avoids to add the script directory or an 
> empty string to sys.path.

'-I' also implies '-s -E' and hence adding isolated to 
args_from_interpreter_flags will also return ['-s', '-E', '-I'] as output and 
hence I suggested modifying the comparison logic.

# Since '-I' implies '-s' and '-E' those flags are also set returning '-s -E -I'

./python.exe --help | rg '\-I'
-I     : isolate Python from the user's environment (implies -E and -s)

./python.exe -I -c 'import sys; print(sys.flags)'
sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, 
no_user_site=1, no_site=0, ignore_environment=1, verbose=0, bytes_warning=0, 
quiet=0, hash_randomization=1, isolated=1, dev_mode=False, utf8_mode=0)

# patching args_from_interpreter_flags to support '-I' would return below

./python.exe -I -c 'import subprocess; 
print(subprocess._args_from_interpreter_flags())'
['-s', '-E', '-I']


Thanks

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34812>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to