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

Skip to content

Commit 84e5217

Browse files
[3.12] gh-106909: Use role :const: for referencing module constants (GH-106910) (GH-106956)
(cherry picked from commit 4b99486)
1 parent 4be0f15 commit 84e5217

Some content is hidden

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

64 files changed

+238
-238
lines changed

Doc/c-api/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ Signal Handling
666666
to interrupt an operation).
667667
668668
If the given signal isn't handled by Python (it was set to
669-
:data:`signal.SIG_DFL` or :data:`signal.SIG_IGN`), it will be ignored.
669+
:py:const:`signal.SIG_DFL` or :py:const:`signal.SIG_IGN`), it will be ignored.
670670
671671
If *signum* is outside of the allowed range of signal numbers, ``-1``
672672
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
@@ -313,9 +313,9 @@ install into it. It is enabled with a simple option::
313313

314314
python setup.py install --user
315315

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

321321
=============== ===========================================================

Doc/library/_thread.rst

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

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

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

7979
.. 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
@@ -403,11 +403,11 @@ Opening network connections
403403
Open a streaming transport connection to a given
404404
address specified by *host* and *port*.
405405

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

410-
The socket type will be :py:data:`~socket.SOCK_STREAM`.
410+
The socket type will be :py:const:`~socket.SOCK_STREAM`.
411411

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

510510
.. versionchanged:: 3.6
511511

512-
The socket option :py:data:`~socket.TCP_NODELAY` is set by default
512+
The socket option :py:const:`~socket.TCP_NODELAY` is set by default
513513
for all TCP connections.
514514

515515
.. versionchanged:: 3.7
@@ -552,11 +552,11 @@ Opening network connections
552552
553553
Create a datagram connection.
554554

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

559-
The socket type will be :py:data:`~socket.SOCK_DGRAM`.
559+
The socket type will be :py:const:`~socket.SOCK_DGRAM`.
560560

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

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

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

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

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

@@ -634,8 +634,8 @@ Opening network connections
634634
635635
Create a Unix connection.
636636

637-
The socket family will be :py:data:`~socket.AF_UNIX`; socket
638-
type will be :py:data:`~socket.SOCK_STREAM`.
637+
The socket family will be :py:const:`~socket.AF_UNIX`; socket
638+
type will be :py:const:`~socket.SOCK_STREAM`.
639639

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

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

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

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

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

@@ -756,7 +756,7 @@ Creating network servers
756756
.. versionchanged:: 3.6
757757

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

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

782782
*path* is the name of a Unix domain socket, and is required,
783783
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
@@ -249,7 +249,7 @@ their completion.
249249

250250
Stop the child process.
251251

252-
On POSIX systems this method sends :py:data:`signal.SIGTERM` to the
252+
On POSIX systems this method sends :py:const:`signal.SIGTERM` to the
253253
child process.
254254

255255
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`, :exc:`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

Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ The module defines the following functions:
172172
which the lock starts, relative to *whence*, and *whence* is as with
173173
:func:`io.IOBase.seek`, specifically:
174174

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

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

203203
Module :mod:`os`
204-
If the locking flags :data:`~os.O_SHLOCK` and :data:`~os.O_EXLOCK` are
204+
If the locking flags :const:`~os.O_SHLOCK` and :const:`~os.O_EXLOCK` are
205205
present in the :mod:`os` module (on BSD only), the :func:`os.open`
206206
function provides an alternative to the :func:`lockf` and :func:`flock`
207207
functions.

Doc/library/ftplib.rst

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

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

446446
.. method:: FTP_TLS.ccc()
447447

Doc/library/http.client.rst

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

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

8888
.. versionchanged:: 3.4
8989
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
@@ -106,7 +106,7 @@ There's also a subclass for secure connections:
106106
.. versionchanged:: 3.4
107107
The class now supports hostname check with
108108
:attr:`ssl.SSLContext.check_hostname` and *Server Name Indication* (see
109-
:data:`ssl.HAS_SNI`).
109+
:const:`ssl.HAS_SNI`).
110110

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

508508

509509
.. 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
@@ -2707,7 +2707,7 @@ handler type) for messages from different processes to get mixed up.
27072707
Returns the logger used by :mod:`multiprocessing`. If necessary, a new one
27082708
will be created.
27092709

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

0 commit comments

Comments
 (0)
0