8000 [3.11] gh-106909: Use role :const: for referencing module constants (… · python/cpython@b338ac7 · GitHub
[go: up one dir, main page]

Skip to content

Commit b338ac7

Browse files
[3.11] gh-106909: Use role :const: for referencing module constants (GH-106910) (GH-106957)
(cherry picked from commit 4b99486)
1 parent cc76113 commit b338ac7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+220
-220
lines changed

Doc/c-api/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ Signal Handling
602602
to interrupt an operation).
603603
604604
If the given signal isn't handled by Python (it was set to
605-
:data:`signal.SIG_DFL` or :data:`signal.SIG_IGN`), it will be ignored.
605+
:py:const:`signal.SIG_DFL` or :py:const:`signal.SIG_IGN`), it will be ignored.
606606
607607
If *signum* is outside of the allowed range of signal numbers, ``-1``
608608
is returned. Otherwise, ``0`` is returned. The error indicator is

Doc/faq/library.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ use ``p.read(n)``.
566566
Note on a bug in popen2: unless your program calls ``wait()`` or
567567
``waitpid()``, finished child processes are never removed, and eventually
568568
calls to popen2 will fail because of a limit on the number of child
569-
processes. Calling :func:`os.waitpid` with the :data:`os.WNOHANG` option can
569+
processes. Calling :func:`os.waitpid` with the :const:`os.WNOHANG` option can
570570
prevent this; a good place to insert such a call would be before calling
571571
``popen2`` again.
572572

Doc/install/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ install into it. It is enabled with a simple option::
309309

310310
python setup.py install --user
311311

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

317317
=============== ===========================================================

Doc/library/_thread.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ This module defines the following constants and functions:
6868
there is no guarantee that the interruption will happen immediately.
6969

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

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

7777
.. versionchanged:: 3.10

Doc/library/asyncio-dev.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ There are several ways to enable asyncio debug mode:
3434
In addition to enabling the debug mode, consider also:
3535

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

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

145-
The default log level is :py:data:`logging.INFO`, which can be easily
145+
The default log level is :py:const:`logging.INFO`, which can be easily
146146
adjusted::
147147

148148
logging.getLogger("asyncio").setLevel(logging.WARNING)

Doc/library/asyncio-eventloop.rst

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,11 @@ Opening network connections
397397
Open a streaming transport connection to a given
398398
address specified by *host* and *port*.
399399

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

404-
The socket type will be :py:data:`~socket.SOCK_STREAM`.
404+
The socket type will be :py:const:`~socket.SOCK_STREAM`.
405405

406406
*protocol_factory* must be a callable returning an
407407
:ref:`asyncio protocol <asyncio-protocol>` implementation.
@@ -495,7 +495,7 @@ Opening network connections
495495

496496
.. versionchanged:: 3.6
497497

498-
The socket option :py:data:`~socket.TCP_NODELAY` is set by default
498+
The socket option :py:const:`~socket.TCP_NODELAY` is set by default
499499
for all TCP connections.
500500

501501
.. versionchanged:: 3.7
@@ -535,11 +535,11 @@ Opening network connections
535535
536536
Create a datagram connection.
537537

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

542-
The socket type will be :py:data:`~socket.SOCK_DGRAM`.
542+
The socket type will be :py:const:`~socket.SOCK_DGRAM`.
543543

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

570570
* *allow_broadcast* tells the kernel to allow this endpoint to send
@@ -590,7 +590,7 @@ Opening network connections
590590

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

596596
When multiple processes with differing UIDs assign sockets to an
@@ -599,7 +599,7 @@ Opening network connections
599599

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

@@ -617,8 +617,8 @@ Opening network connections
617617
618618
Create a Unix connection.
619619

620-
The socket family will be :py:data:`~socket.AF_UNIX`; socket
621-
type will be :py:data:`~socket.SOCK_STREAM`.
620+
The socket family will be :py:const:`~socket.AF_UNIX`; socket
621+
type will be :py:const:`~socket.SOCK_STREAM`.
622622

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

@@ -654,7 +654,7 @@ Creating network servers
654654
ssl_shutdown_timeout=None, \
655655
start_serving=True)
656656
657-
Create a TCP server (socket type :data:`~socket.SOCK_STREAM`) listening
657+
Create a TCP server (socket type :const:`~socket.SOCK_STREAM`) listening
658658
on *port* of the *host* address.
659659

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

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

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

@@ -739,7 +739,7 @@ Creating network servers
739739
.. versionchanged:: 3.6
740740

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

745745
.. versionchanged:: 3.11
@@ -760,7 +760,7 @@ Creating network servers
760760
start_serving=True)
761761
762762
Similar to :meth:`loop.create_server` but works with the
763-
:py:data:`~socket.AF_UNIX` socket family.
763+
:py:const:`~socket.AF_UNIX` socket family.
764764

765765
*path* is the name of a Unix domain socket, and is required,
766766
unless a *sock* argument is provided. Abstract Unix sockets,

Doc/library/asyncio-platforms.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ All event loops on Windows do not support the following methods:
3737

3838
* :meth:`loop.create_unix_connection` and
3939
:meth:`loop.create_unix_server` are not supported.
40-
The :data:`socket.AF_UNIX` socket family is specific to Unix.
40+
The :const:`socket.AF_UNIX` socket family is specific to Unix.
4141

4242
* :meth:`loop.add_signal_handler` and
4343
:meth:`loop.remove_signal_handler` are not supported.

Doc/library/asyncio-subprocess.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ their completion.
244244

245245
Stop the child process.
246246

247-
On POSIX systems this method sends :py:data:`signal.SIGTERM` to the
247+
On POSIX systems this method sends :py:const:`signal.SIGTERM` to the
248248
child process.
249249

250250
On Windows the Win32 API function :c:func:`TerminateProcess` is

Doc/library/exceptions.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,8 @@ depending on the system error code.
659659

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

665665
In addition to those of :exc:`OSError`, :e 10000 xc:`BlockingIOError` can have
666666
one more attribute:
@@ -674,7 +674,7 @@ depending on the system error code.
674674
.. exception:: ChildProcessError
675675

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

679679
.. exception:: ConnectionError
680680

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

693693
.. exception:: ConnectionAbortedError
694694

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

699699
.. exception:: ConnectionRefusedError
700700

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

705705
.. exception:: ConnectionResetError
706706

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

711711
.. exception:: FileExistsError
712712

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

716716
.. exception:: FileNotFoundError
717717

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

721721
.. exception:: InterruptedError
722722

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

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

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

737737
.. exception:: NotADirectoryError
738738

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

745745
.. exception:: PermissionError
746746

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

752752
.. versionchanged:: 3.11.1
753-
WASI's :py:data:`~errno.ENOTCAPABLE` is now mapped to
753+
WASI's :py:const:`~errno.ENOTCAPABLE` is now mapped to
754754
:exc:`PermissionError`.
755755

756756
.. exception:: ProcessLookupError
757757

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

761761
.. exception:: TimeoutError
762762

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

766766
.. versionadded:: 3.3
767767
All the above :exc:`OSError` subclasses were added.

Doc/library/fcntl.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ The module defines the following functions:
166166
which the lock starts, relative to *whence*, and *whence* is as with
167167
:func:`io.IOBase.seek`, specifically:
168168

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

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

197197
Module :mod:`os`
198-
If the locking flags :data:`~os.O_SHLOCK` and :data:`~os.O_EXLOCK` are
198+
If the locking flags :const:`~os.O_SHLOCK` and :const:`~os.O_EXLOCK` are
199199
present in the :mod:`os` module (on BSD only), the :func:`os.open`
200200
function provides an alternative to the :func:`lockf` and :func:`flock`
201201
functions.

Doc/library/ftplib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ The module defines the following items:
108108
.. versionchanged:: 3.4
109109
The class now supports hostname check with
110110
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
111-
:data:`ssl.HAS_SNI`).
111+
:const:`ssl.HAS_SNI`).
112112

113113
.. deprecated:: 3.6
114114

@@ -448,7 +448,7 @@ FTP_TLS Objects
448448
.. versionchanged:: 3.4
449449
The method now supports hostname check with
450450
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
451-
:data:`ssl.HAS_SNI`).
451+
:const:`ssl.HAS_SNI`).
452452

453453
.. method:: FTP_TLS.ccc()
454454

Doc/library/http.client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ The module provides the following classes:
8484

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

8989
.. versionchanged:: 3.4
9090
The *strict* parameter was removed. HTTP 0.9-style "Simple Responses" are

Doc/library/imaplib.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ There's also a subclass for secure connections:
112112
.. versionchanged:: 3.4
113113
The class now supports hostname check with
114114
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
115-
:data:`ssl.HAS_SNI`).
115+
:const:`ssl.HAS_SNI`).
116116

117117
.. deprecated:: 3.6
118118

@@ -513,7 +513,7 @@ An :class:`IMAP4` instance has the following methods:
513513
.. versionchanged:: 3.4
514514
The method now supports hostname check with
515515
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
516-
:data:`ssl.HAS_SNI`).
516+
:const:`ssl.HAS_SNI`).
517517

518518

519519
.. method:: IMAP4.status(mailbox, names)

Doc/library/io.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ I/O Base Classes
423423

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

429429
.. method:: seekable()

Doc/library/multiprocessing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2682,7 +2682,7 @@ handler type) for messages from different processes to get mixed up.
26822682
Returns the logger used by :mod:`multiprocessing`. If necessary, a new one
26832683
will be created.
26842684

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

0 commit comments

Comments
 (0)
0