Skip to content

Commit cc76113

Browse files
[3.11] gh-106892: Use roles :data: and :const: for referencing module variables (GH-106894) (GH-106955)
(cherry picked from commit d036db7)
1 parent 6bde1b9 commit cc76113

38 files changed

+109
-109
lines changed

Doc/c-api/import.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ Importing Modules
126126
read from a Python bytecode file or obtained from the built-in function
127127
:func:`compile`, load the module. Return a new reference to the module object,
128128
or ``NULL`` with an exception set if an error occurred. *name*
129-
is removed from :attr:`sys.modules` in error cases, even if *name* was already
130-
in :attr:`sys.modules` on entry to :c:func:`PyImport_ExecCodeModule`. Leaving
131-
incompletely initialized modules in :attr:`sys.modules` is dangerous, as imports of
129+
is removed from :data:`sys.modules` in error cases, even if *name* was already
130+
in :data:`sys.modules` on entry to :c:func:`PyImport_ExecCodeModule`. Leaving
131+
incompletely initialized modules in :data:`sys.modules` is dangerous, as imports of
132132
such modules have no way to know that the module object is an unknown (and
133133
probably damaged with respect to the module author's intents) state.
134134

Doc/library/__main__.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,12 @@ Note that importing ``__main__`` doesn't cause any issues with unintentionally
336336
running top-level code meant for script use which is put in the
337337
``if __name__ == "__main__"`` block of the ``start`` module. Why does this work?
338338

339-
Python inserts an empty ``__main__`` module in :attr:`sys.modules` at
339+
Python inserts an empty ``__main__`` module in :data:`sys.modules` at
340340
interpreter startup, and populates it by running top-level code. In our example
341341
this is the ``start`` module which runs line by line and imports ``namely``.
342342
In turn, ``namely`` imports ``__main__`` (which is really ``start``). That's an
343343
import cycle! Fortunately, since the partially populated ``__main__``
344-
module is present in :attr:`sys.modules`, Python passes that to ``namely``.
344+
module is present in :data:`sys.modules`, Python passes that to ``namely``.
345345
See :ref:`Special considerations for __main__ <import-dunder-main>` in the
346346
import system's reference for details on how this works.
347347

Doc/library/asyncio-subprocess.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Creating Subprocesses
6868

6969
The *limit* argument sets the buffer limit for :class:`StreamReader`
7070
wrappers for :attr:`Process.stdout` and :attr:`Process.stderr`
71-
(if :attr:`subprocess.PIPE` is passed to *stdout* and *stderr* arguments).
71+
(if :const:`subprocess.PIPE` is passed to *stdout* and *stderr* arguments).
7272

7373
Return a :class:`~asyncio.subprocess.Process` instance.
7474

@@ -86,7 +86,7 @@ Creating Subprocesses
8686

8787
The *limit* argument sets the buffer limit for :class:`StreamReader`
8888
wrappers for :attr:`Process.stdout` and :attr:`Process.stderr`
89-
(if :attr:`subprocess.PIPE` is passed to *stdout* and *stderr* arguments).
89+
(if :const:`subprocess.PIPE` is passed to *stdout* and *stderr* arguments).
9090

9191
Return a :class:`~asyncio.subprocess.Process` instance.
9292

Doc/library/compileall.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ There is no command-line option to control the optimization level used by the
141141
:func:`compile` function, because the Python interpreter itself already
142142
provides the option: :program:`python -O -m compileall`.
143143

144-
Similarly, the :func:`compile` function respects the :attr:`sys.pycache_prefix`
144+
Similarly, the :func:`compile` function respects the :data:`sys.pycache_prefix`
145145
setting. The generated bytecode cache will only be useful if :func:`compile` is
146-
run with the same :attr:`sys.pycache_prefix` (if any) that will be used at
146+
run with the same :data:`sys.pycache_prefix` (if any) that will be used at
147147
runtime.
148148

149149
Public functions

Doc/library/devmode.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Effects of the Python Development Mode:
8181
ignored for empty strings.
8282

8383
* The :class:`io.IOBase` destructor logs ``close()`` exceptions.
84-
* Set the :attr:`~sys.flags.dev_mode` attribute of :attr:`sys.flags` to
84+
* Set the :attr:`~sys.flags.dev_mode` attribute of :data:`sys.flags` to
8585
``True``.
8686

8787
The Python Development Mode does not enable the :mod:`tracemalloc` module by

Doc/library/filecmp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The :class:`dircmp` class
7474

7575
Construct a new directory comparison object, to compare the directories *a*
7676
and *b*. *ignore* is a list of names to ignore, and defaults to
77-
:attr:`filecmp.DEFAULT_IGNORES`. *hide* is a list of names to hide, and
77+
:const:`filecmp.DEFAULT_IGNORES`. *hide* is a list of names to hide, and
7878
defaults to ``[os.curdir, os.pardir]``.
7979

8080
The :class:`dircmp` class compares files by doing *shallow* comparisons

Doc/library/ftplib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ FTP_TLS Objects
438438

439439
.. attribute:: FTP_TLS.ssl_version
440440

441-
The SSL version to use (defaults to :attr:`ssl.PROTOCOL_SSLv23`).
441+
The SSL version to use (defaults to :data:`ssl.PROTOCOL_SSLv23`).
442442

443443
.. method:: FTP_TLS.auth()
444444

Doc/library/functions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ are always available. They are listed here in alphabetical order.
12301230

12311231
* Binary files are buffered in fixed-size chunks; the size of the buffer is
12321232
chosen using a heuristic trying to determine the underlying device's "block
1233-
size" and falling back on :attr:`io.DEFAULT_BUFFER_SIZE`. On many systems,
1233+
size" and falling back on :const:`io.DEFAULT_BUFFER_SIZE`. On many systems,
12341234
the buffer will typically be 4096 or 8192 bytes long.
12351235

12361236
* "Interactive" text files (files for which :meth:`~io.IOBase.isatty`

Doc/library/gc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ values but should not rebind them):
260260

261261
.. versionchanged:: 3.4
262262
Following :pep:`442`, objects with a :meth:`__del__` method don't end
263-
up in :attr:`gc.garbage` anymore.
263+
up in :data:`gc.garbage` anymore.
264264

265265
.. data:: callbacks
266266

Doc/library/gzip.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ Command line options
264264

265265
.. cmdoption:: file
266266

267-
If *file* is not specified, read from :attr:`sys.stdin`.
267+
If *file* is not specified, read from :data:`sys.stdin`.
268268

269269
.. cmdoption:: --fast
270270

0 commit comments

Comments
 (0)