From 0e6584d7b93d5f6b119f7b510cbf134e256ed2ac Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 6 May 2025 08:31:54 -0700 Subject: [PATCH 1/4] docs: note that PYTHONEXECUTABLE is respected with -E/-I options --- Doc/using/cmdline.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 0095046fe1f9f3..198c1c4f687ab8 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -107,8 +107,8 @@ source. :option:`-I` option can be used to run the script in isolated mode where :data:`sys.path` contains neither the current directory nor the user's - site-packages directory. All ``PYTHON*`` environment variables are - ignored, too. + site-packages directory. All ``PYTHON*`` environment variables (except + `PYTHONEXECUTABLE`) are ignored, too. Many standard library modules contain code that is invoked on their execution as a script. An example is the :mod:`timeit` module:: @@ -165,8 +165,8 @@ source. :option:`-I` option can be used to run the script in isolated mode where :data:`sys.path` contains neither the script's directory nor the user's - site-packages directory. All ``PYTHON*`` environment variables are - ignored, too. + site-packages directory. All ``PYTHON*`` environment variables (except + `PYTHONEXECUTABLE`) are ignored, too. .. audit-event:: cpython.run_file filename @@ -285,7 +285,7 @@ Miscellaneous options .. option:: -E - Ignore all ``PYTHON*`` environment variables, e.g. + Ignore all ``PYTHON*`` environment variables (except `PYTHONEXECUTABLE), e.g. :envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set. See also the :option:`-P` and :option:`-I` (isolated) options. @@ -939,8 +939,8 @@ conflict. .. envvar:: PYTHONEXECUTABLE If this environment variable is set, ``sys.argv[0]`` will be set to its - value instead of the value got through the C runtime. Only works on - macOS. + value instead of the value got through the C runtime. This environment + variable isn't ignored by the `-E` and `-I` options. .. envvar:: PYTHONWARNINGS From 22327ff9d7fbbe2108db853da77a0be55ed391b2 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 6 May 2025 10:26:09 -0700 Subject: [PATCH 2/4] add sphinx markup to symbols --- Doc/using/cmdline.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 198c1c4f687ab8..4ac9ee106ff8d0 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -108,7 +108,7 @@ source. :option:`-I` option can be used to run the script in isolated mode where :data:`sys.path` contains neither the current directory nor the user's site-packages directory. All ``PYTHON*`` environment variables (except - `PYTHONEXECUTABLE`) are ignored, too. + :envvar:`PYTHONEXECUTABLE`) are ignored, too. Many standard library modules contain code that is invoked on their execution as a script. An example is the :mod:`timeit` module:: @@ -166,7 +166,7 @@ source. :option:`-I` option can be used to run the script in isolated mode where :data:`sys.path` contains neither the script's directory nor the user's site-packages directory. All ``PYTHON*`` environment variables (except - `PYTHONEXECUTABLE`) are ignored, too. + :envvar:`PYTHONEXECUTABLE`) are ignored, too. .. audit-event:: cpython.run_file filename @@ -285,7 +285,7 @@ Miscellaneous options .. option:: -E - Ignore all ``PYTHON*`` environment variables (except `PYTHONEXECUTABLE), e.g. + Ignore all ``PYTHON*`` environment variables (except :envvar:`PYTHONEXECUTABLE), e.g. :envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set. See also the :option:`-P` and :option:`-I` (isolated) options. @@ -940,7 +940,7 @@ conflict. If this environment variable is set, ``sys.argv[0]`` will be set to its value instead of the value got through the C runtime. This environment - variable isn't ignored by the `-E` and `-I` options. + variable isn't ignored by the :option:`-E` and :option:`-I` options. .. envvar:: PYTHONWARNINGS From 03aa8ce9ff0533e6f1bbde6f80916461a025a474 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Tue, 6 May 2025 10:31:54 -0700 Subject: [PATCH 3/4] add missing backtick Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- Doc/using/cmdline.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 4ac9ee106ff8d0..5222f548b8536b 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -285,7 +285,7 @@ Miscellaneous options .. option:: -E - Ignore all ``PYTHON*`` environment variables (except :envvar:`PYTHONEXECUTABLE), e.g. + Ignore all ``PYTHON*`` environment variables (except :envvar:`PYTHONEXECUTABLE`), e.g. :envvar:`PYTHONPATH` and :envvar:`PYTHONHOME`, that might be set. See also the :option:`-P` and :option:`-I` (isolated) options. From c42d191502548ec4ad7811e5f6f9a5b6d5271be8 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Wed, 7 May 2025 10:16:41 -0700 Subject: [PATCH 4/4] say it affects sys.executable --- Doc/using/cmdline.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 4ac9ee106ff8d0..0e69e4b9922e06 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -938,7 +938,7 @@ conflict. .. envvar:: PYTHONEXECUTABLE - If this environment variable is set, ``sys.argv[0]`` will be set to its + If this environment variable is set, ``sys.executable`` will be set to its value instead of the value got through the C runtime. This environment variable isn't ignored by the :option:`-E` and :option:`-I` options.