bpo-35506: Remove redundant and incorrect links from keywords. (GH-11174)
diff --git a/Doc/library/aifc.rst b/Doc/library/aifc.rst
index 970a7ae..7328907 100644
--- a/Doc/library/aifc.rst
+++ b/Doc/library/aifc.rst
@@ -45,7 +45,7 @@
time how many samples you are going to write in total and use
:meth:`writeframesraw` and :meth:`setnframes`.
The :func:`.open` function may be used in a :keyword:`with` statement. When
- the :keyword:`with` block completes, the :meth:`~aifc.close` method is called.
+ the :keyword:`!with` block completes, the :meth:`~aifc.close` method is called.
.. versionchanged:: 3.4
Support for the :keyword:`with` statement was added.
diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst
index 930c973..017a87a 100644
--- a/Doc/library/contextlib.rst
+++ b/Doc/library/contextlib.rst
@@ -1,5 +1,5 @@
-:mod:`contextlib` --- Utilities for :keyword:`with`\ -statement contexts
-========================================================================
+:mod:`!contextlib` --- Utilities for :keyword:`!with`\ -statement contexts
+==========================================================================
.. module:: contextlib
:synopsis: Utilities for with-statement contexts.
@@ -72,7 +72,7 @@
The function being decorated must return a :term:`generator`-iterator when
called. This iterator must yield exactly one value, which will be bound to
- the targets in the :keyword:`with` statement's :keyword:`as` clause, if any.
+ the targets in the :keyword:`with` statement's :keyword:`!as` clause, if any.
At the point where the generator yields, the block nested in the :keyword:`with`
statement is executed. The generator is then resumed after the block is exited.
@@ -82,9 +82,9 @@
the error (if any), or ensure that some cleanup takes place. If an exception is
trapped merely in order to log it or to perform some action (rather than to
suppress it entirely), the generator must reraise that exception. Otherwise the
- generator context manager will indicate to the :keyword:`with` statement that
+ generator context manager will indicate to the :keyword:`!with` statement that
the exception has been handled, and execution will resume with the statement
- immediately following the :keyword:`with` statement.
+ immediately following the :keyword:`!with` statement.
:func:`contextmanager` uses :class:`ContextDecorator` so the context managers
it creates can be used as decorators as well as in :keyword:`with` statements.
@@ -346,7 +346,7 @@
As the decorated function must be able to be called multiple times, the
underlying context manager must support use in multiple :keyword:`with`
statements. If this is not the case, then the original construct with the
- explicit :keyword:`with` statement inside the function should be used.
+ explicit :keyword:`!with` statement inside the function should be used.
.. versionadded:: 3.2
@@ -771,7 +771,7 @@
More sophisticated context managers may be "reentrant". These context
managers can not only be used in multiple :keyword:`with` statements,
-but may also be used *inside* a :keyword:`with` statement that is already
+but may also be used *inside* a :keyword:`!with` statement that is already
using the same context manager.
:class:`threading.RLock` is an example of a reentrant context manager, as are
diff --git a/Doc/library/fileinput.rst b/Doc/library/fileinput.rst
index f1e29a8..af9dff3 100644
--- a/Doc/library/fileinput.rst
+++ b/Doc/library/fileinput.rst
@@ -63,7 +63,7 @@
The :class:`FileInput` instance can be used as a context manager in the
:keyword:`with` statement. In this example, *input* is closed after the
- :keyword:`with` statement is exited, even if an exception occurs::
+ :keyword:`!with` statement is exited, even if an exception occurs::
with fileinput.input(files=('spam.txt', 'eggs.txt')) as f:
for line in f:
@@ -155,7 +155,7 @@
A :class:`FileInput` instance can be used as a context manager in the
:keyword:`with` statement. In this example, *input* is closed after the
- :keyword:`with` statement is exited, even if an exception occurs::
+ :keyword:`!with` statement is exited, even if an exception occurs::
with FileInput(files=('spam.txt', 'eggs.txt')) as input:
process(input)
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index e7b98eb..24a158f 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1665,7 +1665,7 @@
This function is invoked by the :keyword:`import` statement. It can be
replaced (by importing the :mod:`builtins` module and assigning to
``builtins.__import__``) in order to change semantics of the
- :keyword:`import` statement, but doing so is **strongly** discouraged as it
+ :keyword:`!import` statement, but doing so is **strongly** discouraged as it
is usually simpler to use import hooks (see :pep:`302`) to attain the same
goals and does not cause issues with code which assumes the default import
implementation is in use. Direct use of :func:`__import__` is also
diff --git a/Doc/library/imaplib.rst b/Doc/library/imaplib.rst
index 040dab6..d0709f8 100644
--- a/Doc/library/imaplib.rst
+++ b/Doc/library/imaplib.rst
@@ -39,7 +39,7 @@
The :class:`IMAP4` class supports the :keyword:`with` statement. When used
like this, the IMAP4 ``LOGOUT`` command is issued automatically when the
- :keyword:`with` statement exits. E.g.::
+ :keyword:`!with` statement exits. E.g.::
>>> from imaplib import IMAP4
>>> with IMAP4("domain.org") as M:
diff --git a/Doc/library/imp.rst b/Doc/library/imp.rst
index 1bd6f12..04f207f 100644
--- a/Doc/library/imp.rst
+++ b/Doc/library/imp.rst
@@ -179,7 +179,7 @@
If a module imports objects from another module using :keyword:`from` ...
:keyword:`import` ..., calling :func:`reload` for the other module does not
redefine the objects imported from it --- one way around this is to re-execute
- the :keyword:`from` statement, another is to use :keyword:`import` and qualified
+ the :keyword:`!from` statement, another is to use :keyword:`!import` and qualified
names (*module*.*name*) instead.
If a module instantiates instances of a class, reloading the module that defines
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 0bcfbb1..3c9a99a 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -1,5 +1,5 @@
-:mod:`importlib` --- The implementation of :keyword:`import`
-============================================================
+:mod:`!importlib` --- The implementation of :keyword:`!import`
+==============================================================
.. module:: importlib
:synopsis: The implementation of the import machinery.
@@ -19,7 +19,7 @@
The purpose of the :mod:`importlib` package is two-fold. One is to provide the
implementation of the :keyword:`import` statement (and thus, by extension, the
:func:`__import__` function) in Python source code. This provides an
-implementation of :keyword:`import` which is portable to any Python
+implementation of :keyword:`!import` which is portable to any Python
interpreter. This also provides an implementation which is easier to
comprehend than one implemented in a programming language other than Python.
@@ -197,7 +197,7 @@
If a module imports objects from another module using :keyword:`from` ...
:keyword:`import` ..., calling :func:`reload` for the other module does not
redefine the objects imported from it --- one way around this is to
- re-execute the :keyword:`from` statement, another is to use :keyword:`import`
+ re-execute the :keyword:`!from` statement, another is to use :keyword:`!import`
and qualified names (*module.name*) instead.
If a module instantiates instances of a class, reloading the module that
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index 7068e68..473e8c8 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -249,7 +249,7 @@
:class:`IOBase` is also a context manager and therefore supports the
:keyword:`with` statement. In this example, *file* is closed after the
- :keyword:`with` statement's suite is finished---even if an exception occurs::
+ :keyword:`!with` statement's suite is finished---even if an exception occurs::
with open('spam.txt', 'w') as file:
file.write('Spam and eggs!')
diff --git a/Doc/library/parser.rst b/Doc/library/parser.rst
index c3b699a..a302681 100644
--- a/Doc/library/parser.rst
+++ b/Doc/library/parser.rst
@@ -63,7 +63,7 @@
which have the same form as the parent. An important aspect of this structure
which should be noted is that keywords used to identify the parent node type,
such as the keyword :keyword:`if` in an :const:`if_stmt`, are included in the
-node tree without any special treatment. For example, the :keyword:`if` keyword
+node tree without any special treatment. For example, the :keyword:`!if` keyword
is represented by the tuple ``(1, 'if')``, where ``1`` is the numeric value
associated with all :const:`NAME` tokens, including variable and function names
defined by the user. In an alternate form returned when line number information
diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
index 100a6a1..53eb5d3 100644
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -931,7 +931,7 @@
.. [#] Don't confuse this with the :mod:`marshal` module
.. [#] This is why :keyword:`lambda` functions cannot be pickled: all
- :keyword:`lambda` functions share the same name: ``<lambda>``.
+ :keyword:`!lambda` functions share the same name: ``<lambda>``.
.. [#] The exception raised will likely be an :exc:`ImportError` or an
:exc:`AttributeError` but it could be something else.
diff --git a/Doc/library/smtplib.rst b/Doc/library/smtplib.rst
index f59c184..2c3a5f0 100644
--- a/Doc/library/smtplib.rst
+++ b/Doc/library/smtplib.rst
@@ -46,7 +46,7 @@
The :class:`SMTP` class supports the :keyword:`with` statement. When used
like this, the SMTP ``QUIT`` command is issued automatically when the
- :keyword:`with` statement exits. E.g.::
+ :keyword:`!with` statement exits. E.g.::
>>> from smtplib import SMTP
>>> with SMTP("domain.org") as smtp:
diff --git a/Doc/library/socketserver.rst b/Doc/library/socketserver.rst
index 1b3062d..7c8c8d5 100644
--- a/Doc/library/socketserver.rst
+++ b/Doc/library/socketserver.rst
@@ -57,7 +57,7 @@
:meth:`~BaseServer.handle_request` or
:meth:`~BaseServer.serve_forever` method of the server object to
process one or many requests. Finally, call :meth:`~BaseServer.server_close`
-to close the socket (unless you used a :keyword:`with` statement).
+to close the socket (unless you used a :keyword:`!with` statement).
When inheriting from :class:`ThreadingMixIn` for threaded connection behavior,
you should explicitly declare how you want your threads to behave on an abrupt
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 86e7d68..0262c02 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -74,8 +74,8 @@
.. _boolean:
-Boolean Operations --- :keyword:`and`, :keyword:`or`, :keyword:`not`
-====================================================================
+Boolean Operations --- :keyword:`!and`, :keyword:`!or`, :keyword:`!not`
+=======================================================================
.. index:: pair: Boolean; operations
@@ -4460,7 +4460,7 @@
Enter the runtime context and return either this object or another object
related to the runtime context. The value returned by this method is bound to
- the identifier in the :keyword:`as` clause of :keyword:`with` statements using
+ the identifier in the :keyword:`!as` clause of :keyword:`with` statements using
this context manager.
An example of a context manager that returns itself is a :term:`file object`.
@@ -4472,7 +4472,7 @@
decimal context to a copy of the original decimal context and then return the
copy. This allows changes to be made to the current decimal context in the body
of the :keyword:`with` statement without affecting code outside the
- :keyword:`with` statement.
+ :keyword:`!with` statement.
.. method:: contextmanager.__exit__(exc_type, exc_val, exc_tb)
@@ -4484,10 +4484,10 @@
Returning a true value from this method will cause the :keyword:`with` statement
to suppress the exception and continue execution with the statement immediately
- following the :keyword:`with` statement. Otherwise the exception continues
+ following the :keyword:`!with` statement. Otherwise the exception continues
propagating after this method has finished executing. Exceptions that occur
during execution of this method will replace any exception that occurred in the
- body of the :keyword:`with` statement.
+ body of the :keyword:`!with` statement.
The exception passed in should never be reraised explicitly - instead, this
method should return a false value to indicate that the method completed
diff --git a/Doc/library/telnetlib.rst b/Doc/library/telnetlib.rst
index f9c5153..4ba4264 100644
--- a/Doc/library/telnetlib.rst
+++ b/Doc/library/telnetlib.rst
@@ -44,7 +44,7 @@
an empty string for other reasons. See the individual descriptions below.
A :class:`Telnet` object is a context manager and can be used in a
- :keyword:`with` statement. When the :keyword:`with` block ends, the
+ :keyword:`with` statement. When the :keyword:`!with` block ends, the
:meth:`close` method is called::
>>> from telnetlib import Telnet
diff --git a/Doc/library/tempfile.rst b/Doc/library/tempfile.rst
index 20046ee..daa6f62 100644
--- a/Doc/library/tempfile.rst
+++ b/Doc/library/tempfile.rst
@@ -124,7 +124,7 @@
The directory name can be retrieved from the :attr:`name` attribute of the
returned object. When the returned object is used as a context manager, the
- :attr:`name` will be assigned to the target of the :keyword:`as` clause in
+ :attr:`name` will be assigned to the target of the :keyword:`!as` clause in
the :keyword:`with` statement, if there is one.
The directory can be explicitly cleaned up by calling the
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index a9d5268..d7dbcb1 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -973,8 +973,8 @@
.. _with-locks:
-Using locks, conditions, and semaphores in the :keyword:`with` statement
-------------------------------------------------------------------------
+Using locks, conditions, and semaphores in the :keyword:`!with` statement
+-------------------------------------------------------------------------
All of the objects provided by this module that have :meth:`acquire` and
:meth:`release` methods can be used as context managers for a :keyword:`with`
diff --git a/Doc/library/wave.rst b/Doc/library/wave.rst
index 5c315c5..60d19a8 100644
--- a/Doc/library/wave.rst
+++ b/Doc/library/wave.rst
@@ -40,7 +40,7 @@
the file object.
The :func:`.open` function may be used in a :keyword:`with` statement. When
- the :keyword:`with` block completes, the :meth:`Wave_read.close()
+ the :keyword:`!with` block completes, the :meth:`Wave_read.close()
<wave.Wave_read.close>` or :meth:`Wave_write.close()
<wave.Wave_write.close()>` method is called.
diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst
index fb6fe6e..af09ea9 100644
--- a/Doc/library/xml.dom.minidom.rst
+++ b/Doc/library/xml.dom.minidom.rst
@@ -126,7 +126,7 @@
You can avoid calling this method explicitly by using the :keyword:`with`
statement. The following code will automatically unlink *dom* when the
- :keyword:`with` block is exited::
+ :keyword:`!with` block is exited::
with xml.dom.minidom.parse(datasource) as dom:
... # Work with dom.
diff --git a/Doc/library/zipfile.rst b/Doc/library/zipfile.rst
index 1437730..4e9edff 100644
--- a/Doc/library/zipfile.rst
+++ b/Doc/library/zipfile.rst
@@ -181,7 +181,7 @@
ZipFile is also a context manager and therefore supports the
:keyword:`with` statement. In the example, *myzip* is closed after the
- :keyword:`with` statement's suite is finished---even if an exception occurs::
+ :keyword:`!with` statement's suite is finished---even if an exception occurs::
with ZipFile('spam.zip', 'w') as myzip:
myzip.write('eggs.txt')