@@ -543,6 +543,25 @@ PyConfig
543543
544544 See also the :c:member:`~PyConfig.orig_argv` member.
545545
546+ .. c:member:: int safe_path
547+
548+ If equals to zero, ``Py_RunMain()`` prepends a potentially unsafe path to
549+ :data:`sys.path` at startup:
550+
551+ * If :c:member:`argv[0] <PyConfig.argv>` is equal to ``L"-m"``
552+ (``python -m module ``), prepend the current working directory.
553+ * If running a script (``python script.py ``), prepend the script's
554+ directory. If it's a symbolic link, resolve symbolic links.
555+ * Otherwise (``python -c code `` and ``python ``), prepend an empty string,
556+ which means the current working directory.
557+
558+ Set to 1 by the :option:`-P` command line option and the
559+ :envvar:`PYTHONSAFEPATH` environment variable.
560+
561+ Default: ``0`` in Python config, ``1`` in isolated config.
562+
563+ .. versionadded:: 3.11
564+
546565 .. c:member:: wchar_t* base_exec_prefix
547566
548567 :data:`sys.base_exec_prefix`.
@@ -809,13 +828,14 @@ PyConfig
809828
810829 If greater than 0, enable isolated mode:
811830
812- * :data:`sys.path` contains neither the script's directory (computed from
813- ``argv[0] `` or the current directory) nor the user's site-packages
814- directory.
831+ * Set :c:member:`~PyConfig.safe_path` to 1:
832+ don't prepend a potentially unsafe path to :data:`sys.path` at Python
833+ startup.
834+ * Set :c:member:`~PyConfig.use_environment` to 0.
835+ * Set :c:member:`~PyConfig.user_site_directory` to 0: don't add the user
836+ site directory to :data:`sys.path`.
815837 * Python REPL doesn't import :mod:`readline` nor enable default readline
816838 configuration on interactive prompts.
817- * Set :c:member:`~PyConfig.use_environment` and
818- :c:member:`~PyConfig.user_site_directory` to 0.
819839
820840 Default: ``0`` in Python mode, ``1`` in isolated mode.
821841
@@ -1029,12 +1049,13 @@ PyConfig
10291049 .. c:member:: wchar_t* run_filename
10301050
10311051 Filename passed on the command line: trailing command line argument
1032- without :option:`-c` or :option:`-m`.
1052+ without :option:`-c` or :option:`-m`. It is used by the
1053+ :c:func:`Py_RunMain` function.
10331054
10341055 For example, it is set to ``script.py`` by the ``python3 script.py arg``
1035- command.
1056+ command line .
10361057
1037- Used by :c:func:`Py_RunMain` .
1058+ See also the :c:member:`PyConfig.skip_source_first_line` option .
10381059
10391060 Default: ``NULL``.
10401061
@@ -1419,9 +1440,16 @@ site-package directory to :data:`sys.path`.
14191440The following configuration files are used by the path configuration:
14201441
14211442* ``pyvenv.cfg``
1422- * ``python ._pth`` (Windows only )
1443+ * ``._pth`` file (ex: `` python._pth `` )
14231444* ``pybuilddir.txt`` (Unix only)
14241445
1446+ If a ``._pth`` file is present:
1447+
1448+ * Set :c:member:`~PyConfig.isolated` to 1.
1449+ * Set :c:member:`~PyConfig.use_environment` to 0.
1450+ * Set :c:member:`~PyConfig.site_import` to 0.
1451+ * Set :c:member:`~PyConfig.safe_path` to 1.
1452+
14251453The ``__PYVENV_LAUNCHER__`` environment variable is used to set
14261454:c:member:`PyConfig.base_executable`
14271455
0 commit comments