Skip to content

Commit

Permalink
bpo-35506: Remove redundant and incorrect links from keywords. (pytho…
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored Dec 19, 2018
1 parent 82d7355 commit 2b57c43
Show file tree
Hide file tree
Showing 45 changed files with 240 additions and 242 deletions.
2 changes: 1 addition & 1 deletion Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ Is it possible to write obfuscated one-liners in Python?
--------------------------------------------------------

Yes. Usually this is done by nesting :keyword:`lambda` within
:keyword:`lambda`. See the following three examples, due to Ulf Bartelt::
:keyword:`!lambda`. See the following three examples, due to Ulf Bartelt::

from functools import reduce

Expand Down
6 changes: 3 additions & 3 deletions Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ Glossary
names, attribute access, operators or function calls which all return a
value. In contrast to many other languages, not all language constructs
are expressions. There are also :term:`statement`\s which cannot be used
as expressions, such as :keyword:`if`. Assignments are also statements,
as expressions, such as :keyword:`while`. Assignments are also statements,
not expressions.

extension module
Expand Down Expand Up @@ -448,8 +448,8 @@ Glossary

generator expression
An expression that returns an iterator. It looks like a normal expression
followed by a :keyword:`for` expression defining a loop variable, range,
and an optional :keyword:`if` expression. The combined expression
followed by a :keyword:`!for` clause defining a loop variable, range,
and an optional :keyword:`!if` clause. The combined expression
generates values for an enclosing function::

>>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/functional.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ need to define a new function at all::
existing_files = filter(os.path.exists, file_list)

If the function you need doesn't exist, you need to write it. One way to write
small functions is to use the :keyword:`lambda` statement. ``lambda`` takes a
small functions is to use the :keyword:`lambda` expression. ``lambda`` takes a
number of parameters and an expression combining these parameters, and creates
an anonymous function that returns the value of the expression::

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/aifc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Module :mod:`aifc` defines the following function:
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.
Expand Down
14 changes: 7 additions & 7 deletions Doc/library/contextlib.rst
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -72,7 +72,7 @@ Functions and classes provided:

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.
Expand All @@ -82,9 +82,9 @@ Functions and classes provided:
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.
Expand Down Expand Up @@ -346,7 +346,7 @@ Functions and classes provided:
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

Expand Down Expand Up @@ -771,7 +771,7 @@ Reentrant context managers

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
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/fileinput.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The following function is the primary interface of this module:

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:
Expand Down Expand Up @@ -155,7 +155,7 @@ available for subclassing as well:

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)
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1665,7 +1665,7 @@ are always available. They are listed here in alphabetical order.
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
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/imaplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ base class:

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:
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/imp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ This module provides an interface to the mechanisms used to implement the
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
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -19,7 +19,7 @@ Introduction
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.

Expand Down Expand Up @@ -197,7 +197,7 @@ Functions
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
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ I/O Base Classes

: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!')
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/parser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ of the production as recognized in the input string: these are always sequences
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
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/pickle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ The following example reads the resulting pickled data. ::
.. [#] 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.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/smtplib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Protocol) and :rfc:`1869` (SMTP Service Extensions).

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:
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/socketserver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ the server in a :keyword:`with` statement. Then call the
: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
Expand Down
12 changes: 6 additions & 6 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ one of their operands.)

.. _boolean:

Boolean Operations --- :keyword:`and`, :keyword:`or`, :keyword:`not`
====================================================================
Boolean Operations --- :keyword:`!and`, :keyword:`!or`, :keyword:`!not`
=======================================================================

.. index:: pair: Boolean; operations

Expand Down Expand Up @@ -4460,7 +4460,7 @@ before the statement body is executed and exited when the statement ends:

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`.
Expand All @@ -4472,7 +4472,7 @@ before the statement body is executed and exited when the statement ends:
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)
Expand All @@ -4484,10 +4484,10 @@ before the statement body is executed and exited when the statement ends:

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
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/telnetlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Character), EL (Erase Line), GA (Go Ahead), SB (Subnegotiation Begin).
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
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/tempfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ The module defines the following user-callable items:

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
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/threading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,8 @@ As an example, here is a simple way to synchronize a client and server thread::

.. _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`
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/wave.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The :mod:`wave` module defines the following function and exception:
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.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/xml.dom.minidom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module documentation. This section lists the differences between the API and

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.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/zipfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ ZipFile Objects

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')
Expand Down
Loading

0 comments on commit 2b57c43

Please sign in to comment.