[Python-checkins] (no subject)

Stéphane Wirtel webhook-mailer at python.org
Wed Sep 11 09:36:54 EDT 2019




To: python-checkins at python.org
Subject: bpo-33944: note about the intended use of code in .pth files
 (GH-10131) (GH-15942)
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

https://github.com/python/cpython/commit/d1d968d45df1a900b0600c4d296b180aa978=
336d
commit: d1d968d45df1a900b0600c4d296b180aa978336d
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.co=
m>
committer: St=C3=A9phane Wirtel <stephane at wirtel.be>
date: 2019-09-11T15:36:50+02:00
summary:

bpo-33944: note about the intended use of code in .pth files (GH-10131) (GH-1=
5942)

https://bugs.python.org/issue33944
(cherry picked from commit f9b5840fb4497a9e2ba2c1f01ad0dafba04c8496)

Co-authored-by: native-api <ivan_pozdeev at mail.ru>

files:
A Misc/NEWS.d/next/Documentation/2018-10-26-18-10-29.bpo-33944.V1YeOA.rst
M Doc/library/site.rst

diff --git a/Doc/library/site.rst b/Doc/library/site.rst
index 9e4d402c1f5e..e1ca160c107b 100644
--- a/Doc/library/site.rst
+++ b/Doc/library/site.rst
@@ -61,6 +61,19 @@ directory rather than a file.  No item is added to ``sys.p=
ath`` more than
 once.  Blank lines and lines beginning with ``#`` are skipped.  Lines starti=
ng
 with ``import`` (followed by space or tab) are executed.
=20
+.. 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.
+
 .. index::
    single: package
    triple: path; configuration; file
diff --git a/Misc/NEWS.d/next/Documentation/2018-10-26-18-10-29.bpo-33944.V1Y=
eOA.rst b/Misc/NEWS.d/next/Documentation/2018-10-26-18-10-29.bpo-33944.V1YeOA=
.rst
new file mode 100644
index 000000000000..29bec88c9649
--- /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.



More information about the Python-checkins mailing list