From ed801853b95784f5ceacf08d8076ebf5fdb31211 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Fri, 26 Oct 2018 18:08:53 +0300 Subject: [PATCH 1/3] Added note about the intended use of code in .pth files --- Doc/library/site.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Doc/library/site.rst b/Doc/library/site.rst index 5b5ed93a1b7b63..9e76d69c5f2078 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -57,6 +57,19 @@ 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:: + + 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 the 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. + .. index:: single: package triple: path; configuration; file From e21b7bf262796841cfd617916e1023b2251372c1 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Fri, 26 Oct 2018 18:11:14 +0300 Subject: [PATCH 2/3] NEWS entry --- .../next/Documentation/2018-10-26-18-10-29.bpo-33944.V1YeOA.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Documentation/2018-10-26-18-10-29.bpo-33944.V1YeOA.rst diff --git a/Misc/NEWS.d/next/Documentation/2018-10-26-18-10-29.bpo-33944.V1YeOA.rst b/Misc/NEWS.d/next/Documentation/2018-10-26-18-10-29.bpo-33944.V1YeOA.rst new file mode 100644 index 00000000000000..29bec88c96495f --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2018-10-26-18-10-29.bpo-33944.V1YeOA.rst @@ -0,0 +1 @@ +Added a note about the intended use of code in .pth files. From e33dce59515a8f14104057dc96af7a05fc0f3e65 Mon Sep 17 00:00:00 2001 From: Ivan Pozdeev Date: Fri, 26 Oct 2018 21:03:25 +0300 Subject: [PATCH 3/3] fix a vague expression --- Doc/library/site.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/site.rst b/Doc/library/site.rst index 9e76d69c5f2078..01dd2248f6e3d9 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -62,7 +62,7 @@ with ``import`` (followed by space or tab) are executed. 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 the lines is to make the + 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