Skip to content

Commit a9f8cf0

Browse files
authored
[3.11] gh-101100: Fix Sphinx warnings in whatsnew/2.0.rst (GH-112351) (#115903)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent c078920 commit a9f8cf0

File tree

2 files changed

+53
-53
lines changed

2 files changed

+53
-53
lines changed

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ Doc/reference/compound_stmts.rst
8484
Doc/reference/datamodel.rst
8585
Doc/tutorial/datastructures.rst
8686
Doc/using/windows.rst
87-
Doc/whatsnew/2.0.rst
8887
Doc/whatsnew/2.1.rst
8988
Doc/whatsnew/2.4.rst
9089
Doc/whatsnew/2.5.rst

Doc/whatsnew/2.0.rst

Lines changed: 53 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ often use the ``codecs.lookup(encoding)`` function, which returns a
217217
was consumed.
218218

219219
* *stream_reader* is a class that supports decoding input from a stream.
220-
*stream_reader(file_obj)* returns an object that supports the :meth:`read`,
221-
:meth:`readline`, and :meth:`readlines` methods. These methods will all
220+
*stream_reader(file_obj)* returns an object that supports the :meth:`!read`,
221+
:meth:`!readline`, and :meth:`!readlines` methods. These methods will all
222222
translate from the given encoding and return Unicode strings.
223223

224224
* *stream_writer*, similarly, is a class that supports encoding output to a
225225
stream. *stream_writer(file_obj)* returns an object that supports the
226-
:meth:`write` and :meth:`writelines` methods. These methods expect Unicode
226+
:meth:`!write` and :meth:`!writelines` methods. These methods expect Unicode
227227
strings, translating them to the given encoding on output.
228228

229229
For example, the following code writes a Unicode string into a file, encoding
@@ -356,8 +356,8 @@ variable ``a`` by 2, equivalent to the slightly lengthier ``a = a + 2``.
356356
The full list of supported assignment operators is ``+=``, ``-=``, ``*=``,
357357
``/=``, ``%=``, ``**=``, ``&=``, ``|=``, ``^=``, ``>>=``, and ``<<=``. Python
358358
classes can override the augmented assignment operators by defining methods
359-
named :meth:`__iadd__`, :meth:`__isub__`, etc. For example, the following
360-
:class:`Number` class stores a number and supports using += to create a new
359+
named :meth:`!__iadd__`, :meth:`!__isub__`, etc. For example, the following
360+
:class:`!Number` class stores a number and supports using += to create a new
361361
instance with an incremented value.
362362

363363
.. The empty groups below prevent conversion to guillemets.
@@ -374,7 +374,7 @@ instance with an incremented value.
374374
n += 3
375375
print n.value
376376

377-
The :meth:`__iadd__` special method is called with the value of the increment,
377+
The :meth:`!__iadd__` special method is called with the value of the increment,
378378
and should return a new instance with an appropriately modified value; this
379379
return value is bound as the new value of the variable on the left-hand side.
380380

@@ -390,10 +390,10 @@ String Methods
390390
==============
391391

392392
Until now string-manipulation functionality was in the :mod:`string` module,
393-
which was usually a front-end for the :mod:`strop` module written in C. The
394-
addition of Unicode posed a difficulty for the :mod:`strop` module, because the
393+
which was usually a front-end for the :mod:`!strop` module written in C. The
394+
addition of Unicode posed a difficulty for the :mod:`!strop` module, because the
395395
functions would all need to be rewritten in order to accept either 8-bit or
396-
Unicode strings. For functions such as :func:`string.replace`, which takes 3
396+
Unicode strings. For functions such as :func:`!string.replace`, which takes 3
397397
string arguments, that means eight possible permutations, and correspondingly
398398
complicated code.
399399

@@ -416,13 +416,13 @@ The old :mod:`string` module is still around for backwards compatibility, but it
416416
mostly acts as a front-end to the new string methods.
417417

418418
Two methods which have no parallel in pre-2.0 versions, although they did exist
419-
in JPython for quite some time, are :meth:`startswith` and :meth:`endswith`.
419+
in JPython for quite some time, are :meth:`!startswith` and :meth:`!endswith`.
420420
``s.startswith(t)`` is equivalent to ``s[:len(t)] == t``, while
421421
``s.endswith(t)`` is equivalent to ``s[-len(t):] == t``.
422422

423-
One other method which deserves special mention is :meth:`join`. The
424-
:meth:`join` method of a string receives one parameter, a sequence of strings,
425-
and is equivalent to the :func:`string.join` function from the old :mod:`string`
423+
One other method which deserves special mention is :meth:`!join`. The
424+
:meth:`!join` method of a string receives one parameter, a sequence of strings,
425+
and is equivalent to the :func:`!string.join` function from the old :mod:`string`
426426
module, with the arguments reversed. In other words, ``s.join(seq)`` is
427427
equivalent to the old ``string.join(seq, s)``.
428428

@@ -503,9 +503,9 @@ Minor Language Changes
503503

504504
A new syntax makes it more convenient to call a given function with a tuple of
505505
arguments and/or a dictionary of keyword arguments. In Python 1.5 and earlier,
506-
you'd use the :func:`apply` built-in function: ``apply(f, args, kw)`` calls the
507-
function :func:`f` with the argument tuple *args* and the keyword arguments in
508-
the dictionary *kw*. :func:`apply` is the same in 2.0, but thanks to a patch
506+
you'd use the :func:`!apply` built-in function: ``apply(f, args, kw)`` calls the
507+
function :func:`!f` with the argument tuple *args* and the keyword arguments in
508+
the dictionary *kw*. :func:`!apply` is the same in 2.0, but thanks to a patch
509509
from Greg Ewing, ``f(*args, **kw)`` is a shorter and clearer way to achieve the
510510
same effect. This syntax is symmetrical with the syntax for defining
511511
functions::
@@ -518,7 +518,7 @@ functions::
518518
The ``print`` statement can now have its output directed to a file-like
519519
object by following the ``print`` with ``>> file``, similar to the
520520
redirection operator in Unix shells. Previously you'd either have to use the
521-
:meth:`write` method of the file-like object, which lacks the convenience and
521+
:meth:`!write` method of the file-like object, which lacks the convenience and
522522
simplicity of ``print``, or you could assign a new value to
523523
``sys.stdout`` and then restore the old value. For sending output to standard
524524
error, it's much easier to write this::
@@ -540,7 +540,7 @@ Previously there was no way to implement a class that overrode Python's built-in
540540
true if *obj* is present in the sequence *seq*; Python computes this by simply
541541
trying every index of the sequence until either *obj* is found or an
542542
:exc:`IndexError` is encountered. Moshe Zadka contributed a patch which adds a
543-
:meth:`__contains__` magic method for providing a custom implementation for
543+
:meth:`!__contains__` magic method for providing a custom implementation for
544544
:keyword:`!in`. Additionally, new built-in objects written in C can define what
545545
:keyword:`!in` means for them via a new slot in the sequence protocol.
546546

@@ -562,7 +562,7 @@ the python-dev mailing list for the discussion leading up to this
562562
implementation, and some useful relevant links. Note that comparisons can now
563563
also raise exceptions. In earlier versions of Python, a comparison operation
564564
such as ``cmp(a,b)`` would always produce an answer, even if a user-defined
565-
:meth:`__cmp__` method encountered an error, since the resulting exception would
565+
:meth:`!__cmp__` method encountered an error, since the resulting exception would
566566
simply be silently swallowed.
567567

568568
.. Starting URL:
@@ -607,7 +607,7 @@ seq1, seq2)`` is that :func:`map` pads the sequences with ``None`` if the
607607
sequences aren't all of the same length, while :func:`zip` truncates the
608608
returned list to the length of the shortest argument sequence.
609609

610-
The :func:`int` and :func:`long` functions now accept an optional "base"
610+
The :func:`int` and :func:`!long` functions now accept an optional "base"
611611
parameter when the first argument is a string. ``int('123', 10)`` returns 123,
612612
while ``int('123', 16)`` returns 291. ``int(123, 16)`` raises a
613613
:exc:`TypeError` exception with the message "can't convert non-string with
@@ -620,8 +620,8 @@ would be ``(2, 0, 1, 'beta', 1)``. *level* is a string such as ``"alpha"``,
620620
``"beta"``, or ``"final"`` for a final release.
621621

622622
Dictionaries have an odd new method, ``setdefault(key, default)``, which
623-
behaves similarly to the existing :meth:`get` method. However, if the key is
624-
missing, :meth:`setdefault` both returns the value of *default* as :meth:`get`
623+
behaves similarly to the existing :meth:`!get` method. However, if the key is
624+
missing, :meth:`!setdefault` both returns the value of *default* as :meth:`!get`
625625
would do, and also inserts it into the dictionary as the value for *key*. Thus,
626626
the following lines of code::
627627

@@ -656,7 +656,7 @@ break.
656656
The change which will probably break the most code is tightening up the
657657
arguments accepted by some methods. Some methods would take multiple arguments
658658
and treat them as a tuple, particularly various list methods such as
659-
:meth:`append` and :meth:`insert`. In earlier versions of Python, if ``L`` is
659+
:meth:`!append` and :meth:`!insert`. In earlier versions of Python, if ``L`` is
660660
a list, ``L.append( 1,2 )`` appends the tuple ``(1,2)`` to the list. In Python
661661
2.0 this causes a :exc:`TypeError` exception to be raised, with the message:
662662
'append requires exactly 1 argument; 2 given'. The fix is to simply add an
@@ -693,15 +693,15 @@ advantage of this fact will break in 2.0.
693693

694694
Some work has been done to make integers and long integers a bit more
695695
interchangeable. In 1.5.2, large-file support was added for Solaris, to allow
696-
reading files larger than 2 GiB; this made the :meth:`tell` method of file
696+
reading files larger than 2 GiB; this made the :meth:`!tell` method of file
697697
objects return a long integer instead of a regular integer. Some code would
698698
subtract two file offsets and attempt to use the result to multiply a sequence
699699
or slice a string, but this raised a :exc:`TypeError`. In 2.0, long integers
700700
can be used to multiply or slice a sequence, and it'll behave as you'd
701701
intuitively expect it to; ``3L * 'abc'`` produces 'abcabcabc', and
702702
``(0,1,2,3)[2L:4L]`` produces (2,3). Long integers can also be used in various
703703
contexts where previously only integers were accepted, such as in the
704-
:meth:`seek` method of file objects, and in the formats supported by the ``%``
704+
:meth:`!seek` method of file objects, and in the formats supported by the ``%``
705705
operator (``%d``, ``%i``, ``%x``, etc.). For example, ``"%d" % 2L**64`` will
706706
produce the string ``18446744073709551616``.
707707

@@ -715,15 +715,15 @@ digit.
715715

716716
Taking the :func:`repr` of a float now uses a different formatting precision
717717
than :func:`str`. :func:`repr` uses ``%.17g`` format string for C's
718-
:func:`sprintf`, while :func:`str` uses ``%.12g`` as before. The effect is that
718+
:func:`!sprintf`, while :func:`str` uses ``%.12g`` as before. The effect is that
719719
:func:`repr` may occasionally show more decimal places than :func:`str`, for
720720
certain numbers. For example, the number 8.1 can't be represented exactly in
721721
binary, so ``repr(8.1)`` is ``'8.0999999999999996'``, while str(8.1) is
722722
``'8.1'``.
723723

724724
The ``-X`` command-line option, which turned all standard exceptions into
725725
strings instead of classes, has been removed; the standard exceptions will now
726-
always be classes. The :mod:`exceptions` module containing the standard
726+
always be classes. The :mod:`!exceptions` module containing the standard
727727
exceptions was translated from Python to a built-in C module, written by Barry
728728
Warsaw and Fredrik Lundh.
729729

@@ -879,11 +879,11 @@ joins the basic set of Python documentation.
879879
XML Modules
880880
===========
881881

882-
Python 1.5.2 included a simple XML parser in the form of the :mod:`xmllib`
882+
Python 1.5.2 included a simple XML parser in the form of the :mod:`!xmllib`
883883
module, contributed by Sjoerd Mullender. Since 1.5.2's release, two different
884884
interfaces for processing XML have become common: SAX2 (version 2 of the Simple
885885
API for XML) provides an event-driven interface with some similarities to
886-
:mod:`xmllib`, and the DOM (Document Object Model) provides a tree-based
886+
:mod:`!xmllib`, and the DOM (Document Object Model) provides a tree-based
887887
interface, transforming an XML document into a tree of nodes that can be
888888
traversed and modified. Python 2.0 includes a SAX2 interface and a stripped-down
889889
DOM interface as part of the :mod:`xml` package. Here we will give a brief
@@ -898,9 +898,9 @@ SAX2 Support
898898
SAX defines an event-driven interface for parsing XML. To use SAX, you must
899899
write a SAX handler class. Handler classes inherit from various classes
900900
provided by SAX, and override various methods that will then be called by the
901-
XML parser. For example, the :meth:`startElement` and :meth:`endElement`
901+
XML parser. For example, the :meth:`~xml.sax.handler.ContentHandler.startElement` and :meth:`~xml.sax.handler.ContentHandler.endElement`
902902
methods are called for every starting and end tag encountered by the parser, the
903-
:meth:`characters` method is called for every chunk of character data, and so
903+
:meth:`~xml.sax.handler.ContentHandler.characters` method is called for every chunk of character data, and so
904904
forth.
905905

906906
The advantage of the event-driven approach is that the whole document doesn't
@@ -940,8 +940,8 @@ DOM Support
940940
-----------
941941

942942
The Document Object Model is a tree-based representation for an XML document. A
943-
top-level :class:`Document` instance is the root of the tree, and has a single
944-
child which is the top-level :class:`Element` instance. This :class:`Element`
943+
top-level :class:`!Document` instance is the root of the tree, and has a single
944+
child which is the top-level :class:`!Element` instance. This :class:`!Element`
945945
has children nodes representing character data and any sub-elements, which may
946946
have further children of their own, and so forth. Using the DOM you can
947947
traverse the resulting tree any way you like, access element and attribute
@@ -955,18 +955,18 @@ simply writing ``<tag1>``...\ ``</tag1>`` to a file.
955955

956956
The DOM implementation included with Python lives in the :mod:`xml.dom.minidom`
957957
module. It's a lightweight implementation of the Level 1 DOM with support for
958-
XML namespaces. The :func:`parse` and :func:`parseString` convenience
958+
XML namespaces. The :func:`!parse` and :func:`!parseString` convenience
959959
functions are provided for generating a DOM tree::
960960

961961
from xml.dom import minidom
962962
doc = minidom.parse('hamlet.xml')
963963

964-
``doc`` is a :class:`Document` instance. :class:`Document`, like all the other
965-
DOM classes such as :class:`Element` and :class:`Text`, is a subclass of the
966-
:class:`Node` base class. All the nodes in a DOM tree therefore support certain
967-
common methods, such as :meth:`toxml` which returns a string containing the XML
964+
``doc`` is a :class:`!Document` instance. :class:`!Document`, like all the other
965+
DOM classes such as :class:`!Element` and :class:`Text`, is a subclass of the
966+
:class:`!Node` base class. All the nodes in a DOM tree therefore support certain
967+
common methods, such as :meth:`!toxml` which returns a string containing the XML
968968
representation of the node and its children. Each class also has special
969-
methods of its own; for example, :class:`Element` and :class:`Document`
969+
methods of its own; for example, :class:`!Element` and :class:`!Document`
970970
instances have a method to find all child elements with a given tag name.
971971
Continuing from the previous 2-line example::
972972

@@ -995,7 +995,7 @@ its children can be easily modified by deleting, adding, or removing nodes::
995995
root.insertBefore( root.childNodes[0], root.childNodes[20] )
996996

997997
Again, I will refer you to the Python documentation for a complete listing of
998-
the different :class:`Node` classes and their various methods.
998+
the different :class:`!Node` classes and their various methods.
999999

10001000

10011001
Relationship to PyXML
@@ -1020,7 +1020,7 @@ features in PyXML include:
10201020

10211021
* The xmlproc validating parser, written by Lars Marius Garshol.
10221022

1023-
* The :mod:`sgmlop` parser accelerator module, written by Fredrik Lundh.
1023+
* The :mod:`!sgmlop` parser accelerator module, written by Fredrik Lundh.
10241024

10251025
.. ======================================================================
10261026
@@ -1031,7 +1031,7 @@ Module changes
10311031
Lots of improvements and bugfixes were made to Python's extensive standard
10321032
library; some of the affected modules include :mod:`readline`,
10331033
:mod:`ConfigParser <configparser>`, :mod:`cgi`, :mod:`calendar`, :mod:`posix`, :mod:`readline`,
1034-
:mod:`xmllib`, :mod:`aifc`, :mod:`chunk, wave`, :mod:`random`, :mod:`shelve`,
1034+
:mod:`!xmllib`, :mod:`aifc`, :mod:`chunk`, :mod:`wave`, :mod:`random`, :mod:`shelve`,
10351035
and :mod:`nntplib`. Consult the CVS logs for the exact patch-by-patch details.
10361036

10371037
Brian Gallew contributed OpenSSL support for the :mod:`socket` module. OpenSSL
@@ -1044,11 +1044,12 @@ were also changed to support ``https://`` URLs, though no one has implemented
10441044
FTP or SMTP over SSL.
10451045

10461046
The :mod:`httplib <http>` module has been rewritten by Greg Stein to support HTTP/1.1.
1047+
10471048
Backward compatibility with the 1.5 version of :mod:`!httplib` is provided,
10481049
though using HTTP/1.1 features such as pipelining will require rewriting code to
10491050
use a different set of interfaces.
10501051

1051-
The :mod:`Tkinter` module now supports Tcl/Tk version 8.1, 8.2, or 8.3, and
1052+
The :mod:`!Tkinter` module now supports Tcl/Tk version 8.1, 8.2, or 8.3, and
10521053
support for the older 7.x versions has been dropped. The Tkinter module now
10531054
supports displaying Unicode strings in Tk widgets. Also, Fredrik Lundh
10541055
contributed an optimization which makes operations like ``create_line`` and
@@ -1083,11 +1084,11 @@ module.
10831084
calling :func:`atexit.register` with the function to be called on exit.
10841085
(Contributed by Skip Montanaro.)
10851086

1086-
* :mod:`codecs`, :mod:`encodings`, :mod:`unicodedata`: Added as part of the new
1087+
* :mod:`codecs`, :mod:`!encodings`, :mod:`unicodedata`: Added as part of the new
10871088
Unicode support.
10881089

1089-
* :mod:`filecmp`: Supersedes the old :mod:`cmp`, :mod:`cmpcache` and
1090-
:mod:`dircmp` modules, which have now become deprecated. (Contributed by Gordon
1090+
* :mod:`filecmp`: Supersedes the old :mod:`!cmp`, :mod:`!cmpcache` and
1091+
:mod:`!dircmp` modules, which have now become deprecated. (Contributed by Gordon
10911092
MacMillan and Moshe Zadka.)
10921093

10931094
* :mod:`gettext`: This module provides internationalization (I18N) and
@@ -1105,7 +1106,7 @@ module.
11051106
be passed to functions that expect ordinary strings, such as the :mod:`re`
11061107
module. (Contributed by Sam Rushing, with some extensions by A.M. Kuchling.)
11071108

1108-
* :mod:`pyexpat`: An interface to the Expat XML parser. (Contributed by Paul
1109+
* :mod:`!pyexpat`: An interface to the Expat XML parser. (Contributed by Paul
11091110
Prescod.)
11101111

11111112
* :mod:`robotparser <urllib.robotparser>`: Parse a :file:`robots.txt` file, which is used for writing
@@ -1117,7 +1118,7 @@ module.
11171118
* :mod:`tabnanny`: A module/script to check Python source code for ambiguous
11181119
indentation. (Contributed by Tim Peters.)
11191120

1120-
* :mod:`UserString`: A base class useful for deriving objects that behave like
1121+
* :mod:`!UserString`: A base class useful for deriving objects that behave like
11211122
strings.
11221123

11231124
* :mod:`webbrowser`: A module that provides a platform independent way to launch
@@ -1184,13 +1185,13 @@ Deleted and Deprecated Modules
11841185
==============================
11851186

11861187
A few modules have been dropped because they're obsolete, or because there are
1187-
now better ways to do the same thing. The :mod:`stdwin` module is gone; it was
1188+
now better ways to do the same thing. The :mod:`!stdwin` module is gone; it was
11881189
for a platform-independent windowing toolkit that's no longer developed.
11891190

11901191
A number of modules have been moved to the :file:`lib-old` subdirectory:
1191-
:mod:`cmp`, :mod:`cmpcache`, :mod:`dircmp`, :mod:`dump`, :mod:`find`,
1192-
:mod:`grep`, :mod:`packmail`, :mod:`poly`, :mod:`util`, :mod:`whatsound`,
1193-
:mod:`zmod`. If you have code which relies on a module that's been moved to
1192+
:mod:`!cmp`, :mod:`!cmpcache`, :mod:`!dircmp`, :mod:`!dump`, :mod:`!find`,
1193+
:mod:`!grep`, :mod:`!packmail`, :mod:`!poly`, :mod:`!util`, :mod:`!whatsound`,
1194+
:mod:`!zmod`. If you have code which relies on a module that's been moved to
11941195
:file:`lib-old`, you can simply add that directory to ``sys.path`` to get them
11951196
back, but you're encouraged to update any code that uses these modules.
11961197

0 commit comments

Comments
 (0)