]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-57684: Add -P cmdline option and PYTHONSAFEPATH env var (#31542)
authorVictor Stinner <vstinner@python.org>
Thu, 5 May 2022 23:34:11 +0000 (01:34 +0200)
committerGitHub <noreply@github.com>
Thu, 5 May 2022 23:34:11 +0000 (01:34 +0200)
commitada8b6d1b1b02ae7c38f161c2a0ad866559fe18b
tree2da5c4813d3cf360a121a49268aa9fd2c9fe3cbb
parentf6dd14c65336cda4e2ebccbc6408dfe3b0a68a34
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.
20 files changed:
Doc/c-api/init_config.rst
Doc/library/sys.rst
Doc/using/cmdline.rst
Doc/whatsnew/3.11.rst
Include/cpython/initconfig.h
Lib/subprocess.py
Lib/test/test_cmd_line.py
Lib/test/test_embed.py
Lib/test/test_support.py
Lib/test/test_sys.py
Misc/NEWS.d/next/Security/2022-05-04-14-32-24.gh-issue-57684.HrlDrM.rst [new file with mode: 0644]
Misc/python.man
Modules/getpath.py
Modules/main.c
Programs/_bootstrap_python.c
Programs/_testembed.c
Python/dynload_win.c
Python/getopt.c
Python/initconfig.c
Python/sysmodule.c