From ba7dd6b21e12f830077833c847e1af89c47837e8 Mon Sep 17 00:00:00 2001 From: Muawiya-contact Date: Fri, 30 Jan 2026 11:01:29 +0500 Subject: [PATCH 1/6] gh-144329: Clarify that ._pth files are Windows-only in site docs --- Doc/library/site.rst | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Doc/library/site.rst b/Doc/library/site.rst index d93e4dc7c75f1a..ac15dcb010fc1c 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -78,19 +78,18 @@ directory rather than a file. No item is added to ``sys.path`` more than once. Blank lines and lines beginning with ``#`` are skipped. Lines starting with ``import`` (followed by space or tab) are executed. +.. note:: + On Windows, a file whose name has the form :file:`._pth` is handled + differently; it is used by the Windows-only "embeddable distribution" + to provide a self-contained Python environment. See + :ref:`finding_modules` for more details. + .. note:: An executable line in a :file:`.pth` file is run at every Python startup, regardless of whether a particular module is actually going to be used. Its impact should thus be kept to a minimum. - The primary intended purpose of executable lines is to make the - corresponding module(s) importable - (load 3rd-party import hooks, adjust :envvar:`PATH` etc). - Any other initialization is supposed to be done upon a module's - actual import, if and when it happens. - Limiting a code chunk to a single line is a deliberate measure - to discourage putting anything more complex here. - + .. versionchanged:: 3.13 The :file:`.pth` files are now decoded by UTF-8 at first and then by the :term:`locale encoding` if it fails. From 624857ed59e5833d8d0d6b71bc6dc5994e19ad08 Mon Sep 17 00:00:00 2001 From: Muawiya-contact Date: Fri, 30 Jan 2026 11:30:30 +0500 Subject: [PATCH 2/6] gh-144329: Fix cross-reference label for finding-modules --- Doc/library/site.rst | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Doc/library/site.rst b/Doc/library/site.rst index ac15dcb010fc1c..fa8adc94c33f10 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -82,14 +82,21 @@ with ``import`` (followed by space or tab) are executed. On Windows, a file whose name has the form :file:`._pth` is handled differently; it is used by the Windows-only "embeddable distribution" to provide a self-contained Python environment. See - :ref:`finding_modules` for more details. + :ref:`finding-modules` for more details. .. note:: An executable line in a :file:`.pth` file is run at every Python startup, regardless of whether a particular module is actually going to be used. Its impact should thus be kept to a minimum. - + The primary intended purpose of executable lines is to make the + corresponding module(s) importable + (load 3rd-party import hooks, adjust :envvar:`PATH` etc). + Any other initialization is supposed to be done upon a module's + actual import, if and when it happens. + Limiting a code chunk to a single line is a deliberate measure + to discourage putting anything more complex here. + .. versionchanged:: 3.13 The :file:`.pth` files are now decoded by UTF-8 at first and then by the :term:`locale encoding` if it fails. @@ -306,5 +313,4 @@ value greater than 2 if there is an error. .. seealso:: * :pep:`370` -- Per user site-packages directory - * :ref:`sys-path-init` -- The initialization of :data:`sys.path`. - + * :ref:`sys-path-init` -- The initialization of :data:`sys.path`. \ No newline at end of file From 991ac603f8269ab7c43f173195e8271c9f22e78f Mon Sep 17 00:00:00 2001 From: Muawiya-contact Date: Fri, 30 Jan 2026 11:41:39 +0500 Subject: [PATCH 3/6] gh-144329: Final fix for cross-reference and documentation linting --- Doc/library/site.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/site.rst b/Doc/library/site.rst index fa8adc94c33f10..e8cc7dcb536c3c 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -79,9 +79,10 @@ once. Blank lines and lines beginning with ``#`` are skipped. Lines starting with ``import`` (followed by space or tab) are executed. .. note:: - On Windows, a file whose name has the form :file:`._pth` is handled - differently; it is used by the Windows-only "embeddable distribution" - to provide a self-contained Python environment. See + + On Windows, a file whose name has the form :file:`._pth` is handled + differently; it is used by the Windows-only "embeddable distribution" + to provide a self-contained Python environment. See :ref:`finding-modules` for more details. .. note:: From b9a816f5b5e046d07b68ce99af10375d48a1cb18 Mon Sep 17 00:00:00 2001 From: Muawiya-contact Date: Fri, 30 Jan 2026 11:47:20 +0500 Subject: [PATCH 4/6] gh-144329: final fix for typo, phrasing, and missing newline --- Doc/library/site.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Doc/library/site.rst b/Doc/library/site.rst index e8cc7dcb536c3c..8da4801a209e6d 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -81,9 +81,8 @@ with ``import`` (followed by space or tab) are executed. .. note:: On Windows, a file whose name has the form :file:`._pth` is handled - differently; it is used by the Windows-only "embeddable distribution" - to provide a self-contained Python environment. See - :ref:`finding-modules` for more details. + differently; it is used exclusively by the Windows-only "embeddable + distribution" to provide a self-contained Python environment. .. note:: From d265993f6f610df0e2aba8f1489d567ee47fd3b5 Mon Sep 17 00:00:00 2001 From: Muawiya-contact Date: Fri, 30 Jan 2026 11:52:48 +0500 Subject: [PATCH 5/6] gh-144329: final fix for missing newline at end of file --- Doc/library/site.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/site.rst b/Doc/library/site.rst index 8da4801a209e6d..37e9e0c296eda3 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -313,4 +313,5 @@ value greater than 2 if there is an error. .. seealso:: * :pep:`370` -- Per user site-packages directory - * :ref:`sys-path-init` -- The initialization of :data:`sys.path`. \ No newline at end of file + * :ref:`sys-path-init` -- The initialization of :data:`sys.path`. + \ No newline at end of file From a1d20df90a5fda72d182206c6f935a0a0c2ad365 Mon Sep 17 00:00:00 2001 From: Muawiya-contact Date: Fri, 30 Jan 2026 11:59:40 +0500 Subject: [PATCH 6/6] gh-144329: strip invisible trailing whitespace --- Doc/library/site.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/library/site.rst b/Doc/library/site.rst index 37e9e0c296eda3..03d6278ac86dd8 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -314,4 +314,3 @@ value greater than 2 if there is an error. * :pep:`370` -- Per user site-packages directory * :ref:`sys-path-init` -- The initialization of :data:`sys.path`. - \ No newline at end of file