Skip to content

Commit

Permalink
[3.12] pythongh-106909: Use role :const: for referencing module const…
Browse files Browse the repository at this point in the history
…ants (pythonGH-106910).

(cherry picked from commit 4b99486)

Co-authored-by: Serhiy Storchaka <[email protected]>
  • Loading branch information
serhiy-storchaka committed Jul 21, 2023
1 parent 807afda commit f8d9a26
Show file tree
Hide file tree
Showing 64 changed files with 238 additions and 238 deletions.
2 changes: 1 addition & 1 deletion Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ Signal Handling
to interrupt an operation).
If the given signal isn't handled by Python (it was set to
:data:`signal.SIG_DFL` or :data:`signal.SIG_IGN`), it will be ignored.
:py:const:`signal.SIG_DFL` or :py:const:`signal.SIG_IGN`), it will be ignored.
If *signum* is outside of the allowed range of signal numbers, ``-1``
is returned. Otherwise, ``0`` is returned. The error indicator is
Expand Down
2 changes: 1 addition & 1 deletion Doc/faq/library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ use ``p.read(n)``.
Note on a bug in popen2: unless your program calls ``wait()`` or
``waitpid()``, finished child processes are never removed, and eventually
calls to popen2 will fail because of a limit on the number of child
processes. Calling :func:`os.waitpid` with the :data:`os.WNOHANG` option can
processes. Calling :func:`os.waitpid` with the :const:`os.WNOHANG` option can
prevent this; a good place to insert such a call would be before calling
``popen2`` again.
Expand Down
4 changes: 2 additions & 2 deletions Doc/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ install into it. It is enabled with a simple option::

python setup.py install --user

Files will be installed into subdirectories of :data:`site.USER_BASE` (written
Files will be installed into subdirectories of :const:`site.USER_BASE` (written
as :file:`{userbase}` hereafter). This scheme installs pure Python modules and
extension modules in the same location (also known as :data:`site.USER_SITE`).
extension modules in the same location (also known as :const:`site.USER_SITE`).
Here are the values for UNIX, including macOS:

=============== ===========================================================
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/_thread.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ This module defines the following constants and functions:
there is no guarantee that the interruption will happen immediately.

If given, *signum* is the number of the signal to simulate.
If *signum* is not given, :data:`signal.SIGINT` is simulated.
If *signum* is not given, :const:`signal.SIGINT` is simulated.

If the given signal isn't handled by Python (it was set to
:data:`signal.SIG_DFL` or :data:`signal.SIG_IGN`), this function does
:const:`signal.SIG_DFL` or :const:`signal.SIG_IGN`), this function does
nothing.

.. versionchanged:: 3.10
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/asyncio-dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ There are several ways to enable asyncio debug mode:
In addition to enabling the debug mode, consider also:

* setting the log level of the :ref:`asyncio logger <asyncio-logger>` to
:py:data:`logging.DEBUG`, for example the following snippet of code
:py:const:`logging.DEBUG`, for example the following snippet of code
can be run at startup of the application::

logging.basicConfig(level=logging.DEBUG)
Expand Down Expand Up @@ -142,7 +142,7 @@ Logging
asyncio uses the :mod:`logging` module and all logging is performed
via the ``"asyncio"`` logger.

The default log level is :py:data:`logging.INFO`, which can be easily
The default log level is :py:const:`logging.INFO`, which can be easily
adjusted::

logging.getLogger("asyncio").setLevel(logging.WARNING)
Expand Down
36 changes: 18 additions & 18 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,11 @@ Opening network connections
Open a streaming transport connection to a given
address specified by *host* and *port*.

The socket family can be either :py:data:`~socket.AF_INET` or
:py:data:`~socket.AF_INET6` depending on *host* (or the *family*
The socket family can be either :py:const:`~socket.AF_INET` or
:py:const:`~socket.AF_INET6` depending on *host* (or the *family*
argument, if provided).

The socket type will be :py:data:`~socket.SOCK_STREAM`.
The socket type will be :py:const:`~socket.SOCK_STREAM`.

*protocol_factory* must be a callable returning an
:ref:`asyncio protocol <asyncio-protocol>` implementation.
Expand Down Expand Up @@ -509,7 +509,7 @@ Opening network connections

.. versionchanged:: 3.6

The socket option :py:data:`~socket.TCP_NODELAY` is set by default
The socket option :py:const:`~socket.TCP_NODELAY` is set by default
for all TCP connections.

.. versionchanged:: 3.7
Expand Down Expand Up @@ -552,11 +552,11 @@ Opening network connections
Create a datagram connection.

The socket family can be either :py:data:`~socket.AF_INET`,
:py:data:`~socket.AF_INET6`, or :py:data:`~socket.AF_UNIX`,
The socket family can be either :py:const:`~socket.AF_INET`,
:py:const:`~socket.AF_INET6`, or :py:const:`~socket.AF_UNIX`,
depending on *host* (or the *family* argument, if provided).

The socket type will be :py:data:`~socket.SOCK_DGRAM`.
The socket type will be :py:const:`~socket.SOCK_DGRAM`.

*protocol_factory* must be a callable returning a
:ref:`protocol <asyncio-protocol>` implementation.
Expand All @@ -581,7 +581,7 @@ Opening network connections
* *reuse_port* tells the kernel to allow this endpoint to be bound to the
same port as other existing endpoints are bound to, so long as they all
set this flag when being created. This option is not supported on Windows
and some Unixes. If the :py:data:`~socket.SO_REUSEPORT` constant is not
and some Unixes. If the :py:const:`~socket.SO_REUSEPORT` constant is not
defined then this capability is unsupported.

* *allow_broadcast* tells the kernel to allow this endpoint to send
Expand All @@ -607,7 +607,7 @@ Opening network connections

.. versionchanged:: 3.8.1
The *reuse_address* parameter is no longer supported, as using
:py:data:`~sockets.SO_REUSEADDR` poses a significant security concern for
:py:const:`~sockets.SO_REUSEADDR` poses a significant security concern for
UDP. Explicitly passing ``reuse_address=True`` will raise an exception.

When multiple processes with differing UIDs assign sockets to an
Expand All @@ -616,7 +616,7 @@ Opening network connections

For supported platforms, *reuse_port* can be used as a replacement for
similar functionality. With *reuse_port*,
:py:data:`~sockets.SO_REUSEPORT` is used instead, which specifically
:py:const:`~sockets.SO_REUSEPORT` is used instead, which specifically
prevents processes with differing UIDs from assigning sockets to the same
socket address.

Expand All @@ -634,8 +634,8 @@ Opening network connections
Create a Unix connection.

The socket family will be :py:data:`~socket.AF_UNIX`; socket
type will be :py:data:`~socket.SOCK_STREAM`.
The socket family will be :py:const:`~socket.AF_UNIX`; socket
type will be :py:const:`~socket.SOCK_STREAM`.

A tuple of ``(transport, protocol)`` is returned on success.

Expand Down Expand Up @@ -671,7 +671,7 @@ Creating network servers
ssl_shutdown_timeout=None, \
start_serving=True)
Create a TCP server (socket type :data:`~socket.SOCK_STREAM`) listening
Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening
on *port* of the *host* address.

Returns a :class:`Server` object.
Expand Down Expand Up @@ -699,10 +699,10 @@ Creating network servers
be selected (note that if *host* resolves to multiple network interfaces,
a different random port will be selected for each interface).

* *family* can be set to either :data:`socket.AF_INET` or
:data:`~socket.AF_INET6` to force the socket to use IPv4 or IPv6.
* *family* can be set to either :const:`socket.AF_INET` or
:const:`~socket.AF_INET6` to force the socket to use IPv4 or IPv6.
If not set, the *family* will be determined from host name
(defaults to :data:`~socket.AF_UNSPEC`).
(defaults to :const:`~socket.AF_UNSPEC`).

* *flags* is a bitmask for :meth:`getaddrinfo`.

Expand Down Expand Up @@ -756,7 +756,7 @@ Creating network servers
.. versionchanged:: 3.6

Added *ssl_handshake_timeout* and *start_serving* parameters.
The socket option :py:data:`~socket.TCP_NODELAY` is set by default
The socket option :py:const:`~socket.TCP_NODELAY` is set by default
for all TCP connections.

.. versionchanged:: 3.11
Expand All @@ -777,7 +777,7 @@ Creating network servers
start_serving=True)
Similar to :meth:`loop.create_server` but works with the
:py:data:`~socket.AF_UNIX` socket family.
:py:const:`~socket.AF_UNIX` socket family.

*path* is the name of a Unix domain socket, and is required,
unless a *sock* argument is provided. Abstract Unix sockets,
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-platforms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ All event loops on Windows do not support the following methods:

* :meth:`loop.create_unix_connection` and
:meth:`loop.create_unix_server` are not supported.
The :data:`socket.AF_UNIX` socket family is specific to Unix.
The :const:`socket.AF_UNIX` socket family is specific to Unix.

* :meth:`loop.add_signal_handler` and
:meth:`loop.remove_signal_handler` are not supported.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-subprocess.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ their completion.

Stop the child process.

On POSIX systems this method sends :py:data:`signal.SIGTERM` to the
On POSIX systems this method sends :py:const:`signal.SIGTERM` to the
child process.

On Windows the Win32 API function :c:func:`TerminateProcess` is
Expand Down
34 changes: 17 additions & 17 deletions Doc/library/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,8 @@ depending on the system error code.

Raised when an operation would block on an object (e.g. socket) set
for non-blocking operation.
Corresponds to :c:data:`errno` :py:data:`~errno.EAGAIN`, :py:data:`~errno.EALREADY`,
:py:data:`~errno.EWOULDBLOCK` and :py:data:`~errno.EINPROGRESS`.
Corresponds to :c:data:`errno` :py:const:`~errno.EAGAIN`, :py:const:`~errno.EALREADY`,
:py:const:`~errno.EWOULDBLOCK` and :py:const:`~errno.EINPROGRESS`.

In addition to those of :exc:`OSError`, :exc:`BlockingIOError` can have
one more attribute:
Expand All @@ -674,7 +674,7 @@ depending on the system error code.
.. exception:: ChildProcessError

Raised when an operation on a child process failed.
Corresponds to :c:data:`errno` :py:data:`~errno.ECHILD`.
Corresponds to :c:data:`errno` :py:const:`~errno.ECHILD`.

.. exception:: ConnectionError

Expand All @@ -688,40 +688,40 @@ depending on the system error code.
A subclass of :exc:`ConnectionError`, raised when trying to write on a
pipe while the other end has been closed, or trying to write on a socket
which has been shutdown for writing.
Corresponds to :c:data:`errno` :py:data:`~errno.EPIPE` and :py:data:`~errno.ESHUTDOWN`.
Corresponds to :c:data:`errno` :py:const:`~errno.EPIPE` and :py:const:`~errno.ESHUTDOWN`.

.. exception:: ConnectionAbortedError

A subclass of :exc:`ConnectionError`, raised when a connection attempt
is aborted by the peer.
Corresponds to :c:data:`errno` :py:data:`~errno.ECONNABORTED`.
Corresponds to :c:data:`errno` :py:const:`~errno.ECONNABORTED`.

.. exception:: ConnectionRefusedError

A subclass of :exc:`ConnectionError`, raised when a connection attempt
is refused by the peer.
Corresponds to :c:data:`errno` :py:data:`~errno.ECONNREFUSED`.
Corresponds to :c:data:`errno` :py:const:`~errno.ECONNREFUSED`.

.. exception:: ConnectionResetError

A subclass of :exc:`ConnectionError`, raised when a connection is
reset by the peer.
Corresponds to :c:data:`errno` :py:data:`~errno.ECONNRESET`.
Corresponds to :c:data:`errno` :py:const:`~errno.ECONNRESET`.

.. exception:: FileExistsError

Raised when trying to create a file or directory which already exists.
Corresponds to :c:data:`errno` :py:data:`~errno.EEXIST`.
Corresponds to :c:data:`errno` :py:const:`~errno.EEXIST`.

.. exception:: FileNotFoundError

Raised when a file or directory is requested but doesn't exist.
Corresponds to :c:data:`errno` :py:data:`~errno.ENOENT`.
Corresponds to :c:data:`errno` :py:const:`~errno.ENOENT`.

.. exception:: InterruptedError

Raised when a system call is interrupted by an incoming signal.
Corresponds to :c:data:`errno` :py:data:`~errno.EINTR`.
Corresponds to :c:data:`errno` :py:const:`~errno.EINTR`.

.. versionchanged:: 3.5
Python now retries system calls when a syscall is interrupted by a
Expand All @@ -732,36 +732,36 @@ depending on the system error code.

Raised when a file operation (such as :func:`os.remove`) is requested
on a directory.
Corresponds to :c:data:`errno` :py:data:`~errno.EISDIR`.
Corresponds to :c:data:`errno` :py:const:`~errno.EISDIR`.

.. exception:: NotADirectoryError

Raised when a directory operation (such as :func:`os.listdir`) is requested on
something which is not a directory. On most POSIX platforms, it may also be
raised if an operation attempts to open or traverse a non-directory file as if
it were a directory.
Corresponds to :c:data:`errno` :py:data:`~errno.ENOTDIR`.
Corresponds to :c:data:`errno` :py:const:`~errno.ENOTDIR`.

.. exception:: PermissionError

Raised when trying to run an operation without the adequate access
rights - for example filesystem permissions.
Corresponds to :c:data:`errno` :py:data:`~errno.EACCES`,
:py:data:`~errno.EPERM`, and :py:data:`~errno.ENOTCAPABLE`.
Corresponds to :c:data:`errno` :py:const:`~errno.EACCES`,
:py:const:`~errno.EPERM`, and :py:const:`~errno.ENOTCAPABLE`.

.. versionchanged:: 3.11.1
WASI's :py:data:`~errno.ENOTCAPABLE` is now mapped to
WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped to
:exc:`PermissionError`.

.. exception:: ProcessLookupError

Raised when a given process doesn't exist.
Corresponds to :c:data:`errno` :py:data:`~errno.ESRCH`.
Corresponds to :c:data:`errno` :py:const:`~errno.ESRCH`.

.. exception:: TimeoutError

Raised when a system function timed out at the system level.
Corresponds to :c:data:`errno` :py:data:`~errno.ETIMEDOUT`.
Corresponds to :c:data:`errno` :py:const:`~errno.ETIMEDOUT`.

.. versionadded:: 3.3
All the above :exc:`OSError` subclasses were added.
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/fcntl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ The module defines the following functions:
which the lock starts, relative to *whence*, and *whence* is as with
:func:`io.IOBase.seek`, specifically:

* :const:`0` -- relative to the start of the file (:data:`os.SEEK_SET`)
* :const:`1` -- relative to the current buffer position (:data:`os.SEEK_CUR`)
* :const:`2` -- relative to the end of the file (:data:`os.SEEK_END`)
* :const:`0` -- relative to the start of the file (:const:`os.SEEK_SET`)
* :const:`1` -- relative to the current buffer position (:const:`os.SEEK_CUR`)
* :const:`2` -- relative to the end of the file (:const:`os.SEEK_END`)

The default for *start* is 0, which means to start at the beginning of the file.
The default for *len* is 0 which means to lock to the end of the file. The
Expand All @@ -201,7 +201,7 @@ using the :func:`flock` call may be better.
.. seealso::

Module :mod:`os`
If the locking flags :data:`~os.O_SHLOCK` and :data:`~os.O_EXLOCK` are
If the locking flags :const:`~os.O_SHLOCK` and :const:`~os.O_EXLOCK` are
present in the :mod:`os` module (on BSD only), the :func:`os.open`
function provides an alternative to the :func:`lockf` and :func:`flock`
functions.
4 changes: 2 additions & 2 deletions Doc/library/ftplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ The module defines the following items:
.. versionchanged:: 3.4
The class now supports hostname check with
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
:data:`ssl.HAS_SNI`).
:const:`ssl.HAS_SNI`).

.. versionchanged:: 3.9
If the *timeout* parameter is set to be zero, it will raise a
Expand Down Expand Up @@ -441,7 +441,7 @@ FTP_TLS Objects
.. versionchanged:: 3.4
The method now supports hostname check with
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
:data:`ssl.HAS_SNI`).
:const:`ssl.HAS_SNI`).

.. method:: FTP_TLS.ccc()

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/http.client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The module provides the following classes:

.. versionchanged:: 3.2
This class now supports HTTPS virtual hosts if possible (that is,
if :data:`ssl.HAS_SNI` is true).
if :const:`ssl.HAS_SNI` is true).

.. versionchanged:: 3.4
The *strict* parameter was removed. HTTP 0.9-style "Simple Responses" are
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/imaplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ There's also a subclass for secure connections:
.. versionchanged:: 3.4
The class now supports hostname check with
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
:data:`ssl.HAS_SNI`).
:const:`ssl.HAS_SNI`).

.. versionchanged:: 3.9
The optional *timeout* parameter was added.
Expand Down Expand Up @@ -503,7 +503,7 @@ An :class:`IMAP4` instance has the following methods:
.. versionchanged:: 3.4
The method now supports hostname check with
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
:data:`ssl.HAS_SNI`).
:const:`ssl.HAS_SNI`).


.. method:: IMAP4.status(mailbox, names)
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ I/O Base Classes

.. versionadded:: 3.3
Some operating systems could support additional values, like
:data:`os.SEEK_HOLE` or :data:`os.SEEK_DATA`. The valid values
:const:`os.SEEK_HOLE` or :const:`os.SEEK_DATA`. The valid values
for a file could depend on it being open in text or binary mode.

.. method:: seekable()
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2707,7 +2707,7 @@ handler type) for messages from different processes to get mixed up.
Returns the logger used by :mod:`multiprocessing`. If necessary, a new one
will be created.

When first created the logger has level :data:`logging.NOTSET` and no
When first created the logger has level :const:`logging.NOTSET` and no
default handler. Messages sent to this logger will not by default propagate
to the root logger.

Expand Down
Loading

0 comments on commit f8d9a26

Please sign in to comment.