Skip to content

Commit 551e12f

Browse files
miss-islingtonhugovkterryjreedy
authored
[3.12] gh-101100: Fix Sphinx warnings in whatsnew/2.1.rst (GH-112357) (#115932)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
1 parent f1b3b34 commit 551e12f

File tree

2 files changed

+37
-38
lines changed

2 files changed

+37
-38
lines changed

Doc/tools/.nitignore

-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ Doc/reference/compound_stmts.rst
9595
Doc/reference/datamodel.rst
9696
Doc/tutorial/datastructures.rst
9797
Doc/using/windows.rst
98-
Doc/whatsnew/2.1.rst
9998
Doc/whatsnew/2.4.rst
10099
Doc/whatsnew/2.5.rst
101100
Doc/whatsnew/2.6.rst

Doc/whatsnew/2.1.rst

+37-37
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ nested recursive function definition doesn't work::
4848
return g(value-1) + 1
4949
...
5050

51-
The function :func:`g` will always raise a :exc:`NameError` exception, because
51+
The function :func:`!g` will always raise a :exc:`NameError` exception, because
5252
the binding of the name ``g`` isn't in either its local namespace or in the
5353
module-level namespace. This isn't much of a problem in practice (how often do
5454
you recursively define interior functions like this?), but this also made using
@@ -104,7 +104,7 @@ To make the preceding explanation a bit clearer, here's an example::
104104

105105
Line 4 containing the ``exec`` statement is a syntax error, since
106106
``exec`` would define a new local variable named ``x`` whose value should
107-
be accessed by :func:`g`.
107+
be accessed by :func:`!g`.
108108

109109
This shouldn't be much of a limitation, since ``exec`` is rarely used in
110110
most Python code (and when it is used, it's often a sign of a poor design
@@ -161,7 +161,7 @@ PEP 207: Rich Comparisons
161161

162162
In earlier versions, Python's support for implementing comparisons on user-defined
163163
classes and extension types was quite simple. Classes could implement a
164-
:meth:`__cmp__` method that was given two instances of a class, and could only
164+
:meth:`!__cmp__` method that was given two instances of a class, and could only
165165
return 0 if they were equal or +1 or -1 if they weren't; the method couldn't
166166
raise an exception or return anything other than a Boolean value. Users of
167167
Numeric Python often found this model too weak and restrictive, because in the
@@ -175,21 +175,21 @@ In Python 2.1, rich comparisons were added in order to support this need.
175175
Python classes can now individually overload each of the ``<``, ``<=``, ``>``,
176176
``>=``, ``==``, and ``!=`` operations. The new magic method names are:
177177

178-
+-----------+----------------+
179-
| Operation | Method name |
180-
+===========+================+
181-
| ``<`` | :meth:`__lt__` |
182-
+-----------+----------------+
183-
| ``<=`` | :meth:`__le__` |
184-
+-----------+----------------+
185-
| ``>`` | :meth:`__gt__` |
186-
+-----------+----------------+
187-
| ``>=`` | :meth:`__ge__` |
188-
+-----------+----------------+
189-
| ``==`` | :meth:`__eq__` |
190-
+-----------+----------------+
191-
| ``!=`` | :meth:`__ne__` |
192-
+-----------+----------------+
178+
+-----------+------------------------+
179+
| Operation | Method name |
180+
+===========+========================+
181+
| ``<`` | :meth:`~object.__lt__` |
182+
+-----------+------------------------+
183+
| ``<=`` | :meth:`~object.__le__` |
184+
+-----------+------------------------+
185+
| ``>`` | :meth:`~object.__gt__` |
186+
+-----------+------------------------+
187+
| ``>=`` | :meth:`~object.__ge__` |
188+
+-----------+------------------------+
189+
| ``==`` | :meth:`~object.__eq__` |
190+
+-----------+------------------------+
191+
| ``!=`` | :meth:`~object.__ne__` |
192+
+-----------+------------------------+
193193

194194
(The magic methods are named after the corresponding Fortran operators ``.LT.``.
195195
``.LE.``, &c. Numeric programmers are almost certainly quite familiar with
@@ -208,7 +208,7 @@ The built-in ``cmp(A,B)`` function can use the rich comparison machinery,
208208
and now accepts an optional argument specifying which comparison operation to
209209
use; this is given as one of the strings ``"<"``, ``"<="``, ``">"``, ``">="``,
210210
``"=="``, or ``"!="``. If called without the optional third argument,
211-
:func:`cmp` will only return -1, 0, or +1 as in previous versions of Python;
211+
:func:`!cmp` will only return -1, 0, or +1 as in previous versions of Python;
212212
otherwise it will call the appropriate method and can return any Python object.
213213

214214
There are also corresponding changes of interest to C programmers; there's a new
@@ -245,7 +245,7 @@ out warnings that you don't want to be displayed. Third-party modules can also
245245
use this framework to deprecate old features that they no longer wish to
246246
support.
247247

248-
For example, in Python 2.1 the :mod:`regex` module is deprecated, so importing
248+
For example, in Python 2.1 the :mod:`!regex` module is deprecated, so importing
249249
it causes a warning to be printed::
250250

251251
>>> import regex
@@ -262,7 +262,7 @@ can be used to specify a particular warning category.
262262

263263
Filters can be added to disable certain warnings; a regular expression pattern
264264
can be applied to the message or to the module name in order to suppress a
265-
warning. For example, you may have a program that uses the :mod:`regex` module
265+
warning. For example, you may have a program that uses the :mod:`!regex` module
266266
and not want to spare the time to convert it to use the :mod:`re` module right
267267
now. The warning can be suppressed by calling ::
268268

@@ -274,7 +274,7 @@ now. The warning can be suppressed by calling ::
274274

275275
This adds a filter that will apply only to warnings of the class
276276
:class:`DeprecationWarning` triggered in the :mod:`__main__` module, and applies
277-
a regular expression to only match the message about the :mod:`regex` module
277+
a regular expression to only match the message about the :mod:`!regex` module
278278
being deprecated, and will cause such warnings to be ignored. Warnings can also
279279
be printed only once, printed every time the offending code is executed, or
280280
turned into exceptions that will cause the program to stop (unless the
@@ -368,7 +368,7 @@ dictionary::
368368
This version works for simple things such as integers, but it has a side effect;
369369
the ``_cache`` dictionary holds a reference to the return values, so they'll
370370
never be deallocated until the Python process exits and cleans up. This isn't
371-
very noticeable for integers, but if :func:`f` returns an object, or a data
371+
very noticeable for integers, but if :func:`!f` returns an object, or a data
372372
structure that takes up a lot of memory, this can be a problem.
373373

374374
Weak references provide a way to implement a cache that won't keep objects alive
@@ -379,7 +379,7 @@ created by calling ``wr = weakref.ref(obj)``. The object being referred to is
379379
returned by calling the weak reference as if it were a function: ``wr()``. It
380380
will return the referenced object, or ``None`` if the object no longer exists.
381381

382-
This makes it possible to write a :func:`memoize` function whose cache doesn't
382+
This makes it possible to write a :func:`!memoize` function whose cache doesn't
383383
keep objects alive, by storing weak references in the cache. ::
384384

385385
_cache = {}
@@ -402,7 +402,7 @@ weak references --- an object referenced only by proxy objects is deallocated --
402402
but instead of requiring an explicit call to retrieve the object, the proxy
403403
transparently forwards all operations to the object as long as the object still
404404
exists. If the object is deallocated, attempting to use a proxy will cause a
405-
:exc:`weakref.ReferenceError` exception to be raised. ::
405+
:exc:`!weakref.ReferenceError` exception to be raised. ::
406406

407407
proxy = weakref.proxy(obj)
408408
proxy.attr # Equivalent to obj.attr
@@ -446,7 +446,7 @@ The dictionary containing attributes can be accessed as the function's
446446
:attr:`~object.__dict__`. Unlike the :attr:`~object.__dict__` attribute of class instances, in
447447
functions you can actually assign a new dictionary to :attr:`~object.__dict__`, though
448448
the new value is restricted to a regular Python dictionary; you *can't* be
449-
tricky and set it to a :class:`UserDict` instance, or any other random object
449+
tricky and set it to a :class:`!UserDict` instance, or any other random object
450450
that behaves like a mapping.
451451

452452

@@ -584,11 +584,11 @@ available from the Distutils SIG at https://www.python.org/community/sigs/curren
584584
New and Improved Modules
585585
========================
586586

587-
* Ka-Ping Yee contributed two new modules: :mod:`inspect.py`, a module for
588-
getting information about live Python code, and :mod:`pydoc.py`, a module for
587+
* Ka-Ping Yee contributed two new modules: :mod:`!inspect.py`, a module for
588+
getting information about live Python code, and :mod:`!pydoc.py`, a module for
589589
interactively converting docstrings to HTML or text. As a bonus,
590590
:file:`Tools/scripts/pydoc`, which is now automatically installed, uses
591-
:mod:`pydoc.py` to display documentation given a Python module, package, or
591+
:mod:`!pydoc.py` to display documentation given a Python module, package, or
592592
class name. For example, ``pydoc xml.dom`` displays the following::
593593

594594
Python Library Documentation: package xml.dom in xml
@@ -617,7 +617,7 @@ New and Improved Modules
617617
Kent Beck's Smalltalk testing framework. See https://pyunit.sourceforge.net/ for
618618
more information about PyUnit.
619619

620-
* The :mod:`difflib` module contains a class, :class:`SequenceMatcher`, which
620+
* The :mod:`difflib` module contains a class, :class:`~difflib.SequenceMatcher`, which
621621
compares two sequences and computes the changes required to transform one
622622
sequence into the other. For example, this module can be used to write a tool
623623
similar to the Unix :program:`diff` program, and in fact the sample program
@@ -633,7 +633,7 @@ New and Improved Modules
633633
2.1 includes an updated version of the :mod:`xml` package. Some of the
634634
noteworthy changes include support for Expat 1.2 and later versions, the ability
635635
for Expat parsers to handle files in any encoding supported by Python, and
636-
various bugfixes for SAX, DOM, and the :mod:`minidom` module.
636+
various bugfixes for SAX, DOM, and the :mod:`!minidom` module.
637637

638638
* Ping also contributed another hook for handling uncaught exceptions.
639639
:func:`sys.excepthook` can be set to a callable object. When an exception isn't
@@ -643,8 +643,8 @@ New and Improved Modules
643643
printing an extended traceback that not only lists the stack frames, but also
644644
lists the function arguments and the local variables for each frame.
645645

646-
* Various functions in the :mod:`time` module, such as :func:`asctime` and
647-
:func:`localtime`, require a floating point argument containing the time in
646+
* Various functions in the :mod:`time` module, such as :func:`~time.asctime` and
647+
:func:`~time.localtime`, require a floating point argument containing the time in
648648
seconds since the epoch. The most common use of these functions is to work with
649649
the current time, so the floating point argument has been made optional; when a
650650
value isn't provided, the current time will be used. For example, log file
@@ -724,10 +724,10 @@ of the more notable changes are:
724724
a discussion in comp.lang.python.
725725

726726
A new module and method for file objects was also added, contributed by Jeff
727-
Epler. The new method, :meth:`xreadlines`, is similar to the existing
728-
:func:`xrange` built-in. :func:`xreadlines` returns an opaque sequence object
727+
Epler. The new method, :meth:`!xreadlines`, is similar to the existing
728+
:func:`!xrange` built-in. :func:`!xreadlines` returns an opaque sequence object
729729
that only supports being iterated over, reading a line on every iteration but
730-
not reading the entire file into memory as the existing :meth:`readlines` method
730+
not reading the entire file into memory as the existing :meth:`!readlines` method
731731
does. You'd use it like this::
732732

733733
for line in sys.stdin.xreadlines():
@@ -737,7 +737,7 @@ of the more notable changes are:
737737
For a fuller discussion of the line I/O changes, see the python-dev summary for
738738
January 1--15, 2001 at https://mail.python.org/pipermail/python-dev/2001-January/.
739739

740-
* A new method, :meth:`popitem`, was added to dictionaries to enable
740+
* A new method, :meth:`~dict.popitem`, was added to dictionaries to enable
741741
destructively iterating through the contents of a dictionary; this can be faster
742742
for large dictionaries because there's no need to construct a list containing
743743
all the keys or values. ``D.popitem()`` removes a random ``(key, value)`` pair

0 commit comments

Comments
 (0)