From 972e1153d7fa019d7a4ac5a0366aabfee8750432 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 30 Sep 2023 17:13:23 +0300 Subject: [PATCH 1/3] gh-101100: Fix sphinx warnings in `library/site.rst` --- Doc/library/exceptions.rst | 12 +++++++++--- Doc/library/site.rst | 16 +++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index fae0cf621323c8..c4d6b900d6bbb5 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -221,9 +221,15 @@ The following exceptions are the exceptions that are usually raised. has a name that cannot be found. The :attr:`name` and :attr:`path` attributes can be set using keyword-only - arguments to the constructor. When set they represent the name of the module - that was attempted to be imported and the path to any file which triggered - the exception, respectively. + arguments to the constructor. When set they represent: + + .. attribute:: name + + The name of the module that was attempted to be imported. + + .. attribute:: path + + The path to any file which triggered the exception. .. versionchanged:: 3.3 Added the :attr:`name` and :attr:`path` attributes. diff --git a/Doc/library/site.rst b/Doc/library/site.rst index ea3b2e996574ef..18a61f328f7128 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -19,7 +19,7 @@ Importing this module will append site-specific paths to the module search path and add a few builtins, unless :option:`-S` was used. In that case, this module can be safely imported with no automatic modifications to the module search path or additions to the builtins. To explicitly trigger the usual site-specific -additions, call the :func:`site.main` function. +additions, call the :func:`main` function. .. versionchanged:: 3.3 Importing the module used to trigger paths manipulation even when using @@ -109,32 +109,34 @@ directory precedes the :file:`foo` directory because :file:`bar.pth` comes alphabetically before :file:`foo.pth`; and :file:`spam` is omitted because it is not mentioned in either path configuration file. -.. index:: pair: module; sitecustomize +.. module:: sitecustomize After these path manipulations, an attempt is made to import a module named :mod:`sitecustomize`, which can perform arbitrary site-specific customizations. It is typically created by a system administrator in the site-packages directory. If this import fails with an :exc:`ImportError` or its subclass -exception, and the exception's :attr:`name` attribute equals to ``'sitecustomize'``, +exception, and the exception's :attr:`~ImportError.name` +attribute equals to ``'sitecustomize'``, it is silently ignored. If Python is started without output streams available, as with :file:`pythonw.exe` on Windows (which is used by default to start IDLE), attempted output from :mod:`sitecustomize` is ignored. Any other exception causes a silent and perhaps mysterious failure of the process. -.. index:: pair: module; usercustomize +.. module:: usercustomize After this, an attempt is made to import a module named :mod:`usercustomize`, which can perform arbitrary user-specific customizations, if -:data:`ENABLE_USER_SITE` is true. This file is intended to be created in the +:data:`~site.ENABLE_USER_SITE` is true. This file is intended to be created in the user site-packages directory (see below), which is part of ``sys.path`` unless disabled by :option:`-s`. If this import fails with an :exc:`ImportError` or -its subclass exception, and the exception's :attr:`name` attribute equals to -``'usercustomize'``, it is silently ignored. +its subclass exception, and the exception's :attr:`~ImportError.name` +attribute equals to ``'usercustomize'``, it is silently ignored. Note that for some non-Unix systems, ``sys.prefix`` and ``sys.exec_prefix`` are empty, and the path manipulations are skipped; however the import of :mod:`sitecustomize` and :mod:`usercustomize` is still attempted. +.. currentmodule:: site .. _rlcompleter-config: From b0d6bbcc4d2e031811750abab6aaf26a284caa72 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 30 Sep 2023 15:36:10 +0100 Subject: [PATCH 2/3] Update .nitignore --- Doc/tools/.nitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index f217da9052ca78..fbc9fc33ecea1b 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -106,7 +106,6 @@ Doc/library/select.rst Doc/library/selectors.rst Doc/library/shelve.rst Doc/library/signal.rst -Doc/library/site.rst Doc/library/smtplib.rst Doc/library/socket.rst Doc/library/socketserver.rst @@ -114,7 +113,6 @@ Doc/library/ssl.rst Doc/library/stdtypes.rst Doc/library/string.rst Doc/library/subprocess.rst -Doc/library/sys_path_init.rst Doc/library/syslog.rst Doc/library/tarfile.rst Doc/library/tempfile.rst From 3ddce15981d687d7521fe03b4ad6c32e86a2c949 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 1 Oct 2023 09:16:46 +0300 Subject: [PATCH 3/3] Address review --- Doc/library/exceptions.rst | 4 ++-- Doc/library/site.rst | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst index c4d6b900d6bbb5..cd85df8723a76b 100644 --- a/Doc/library/exceptions.rst +++ b/Doc/library/exceptions.rst @@ -220,8 +220,8 @@ The following exceptions are the exceptions that are usually raised. load a module. Also raised when the "from list" in ``from ... import`` has a name that cannot be found. - The :attr:`name` and :attr:`path` attributes can be set using keyword-only - arguments to the constructor. When set they represent: + The optional *name* and *path* keyword-only arguments + set the corresponding attributes: .. attribute:: name diff --git a/Doc/library/site.rst b/Doc/library/site.rst index 18a61f328f7128..ebd78917a01373 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -109,6 +109,9 @@ directory precedes the :file:`foo` directory because :file:`bar.pth` comes alphabetically before :file:`foo.pth`; and :file:`spam` is omitted because it is not mentioned in either path configuration file. +:mod:`sitecustomize` +-------------------- + .. module:: sitecustomize After these path manipulations, an attempt is made to import a module named @@ -122,6 +125,9 @@ with :file:`pythonw.exe` on Windows (which is used by default to start IDLE), attempted output from :mod:`sitecustomize` is ignored. Any other exception causes a silent and perhaps mysterious failure of the process. +:mod:`usercustomize` +-------------------- + .. module:: usercustomize After this, an attempt is made to import a module named :mod:`usercustomize`,