Skip to content

Commit a4c8c47

Browse files
committed
#22613: remaining corrections in extending/reference docs (thanks Jacques Ducasse)
1 parent 8ed75cd commit a4c8c47

8 files changed

+44
-54
lines changed

Doc/c-api/arg.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,11 @@ API Functions
429429
430430
Function used to deconstruct the argument lists of "old-style" functions ---
431431
these are functions which use the :const:`METH_OLDARGS` parameter parsing
432-
method. This is not recommended for use in parameter parsing in new code, and
433-
most code in the standard interpreter has been modified to no longer use this
434-
for that purpose. It does remain a convenient way to decompose other tuples,
435-
however, and may continue to be used for that purpose.
432+
method, which has been removed in Python 3. This is not recommended for use
433+
in parameter parsing in new code, and most code in the standard interpreter
434+
has been modified to no longer use this for that purpose. It does remain a
435+
convenient way to decompose other tuples, however, and may continue to be
436+
used for that purpose.
436437
437438
438439
.. c:function:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...)

Doc/extending/extending.rst

+2-5
Original file line numberDiff line numberDiff line change
@@ -857,11 +857,8 @@ reclaim the memory belonging to any objects in a reference cycle, or referenced
857857
from the objects in the cycle, even though there are no further references to
858858
the cycle itself.
859859

860-
The cycle detector is able to detect garbage cycles and can reclaim them so long
861-
as there are no finalizers implemented in Python (:meth:`__del__` methods).
862-
When there are such finalizers, the detector exposes the cycles through the
863-
:mod:`gc` module (specifically, the :attr:`~gc.garbage` variable in that module).
864-
The :mod:`gc` module also exposes a way to run the detector (the
860+
The cycle detector is able to detect garbage cycles and can reclaim them.
861+
The :mod:`gc` module exposes a way to run the detector (the
865862
:func:`~gc.collect` function), as well as configuration
866863
interfaces and the ability to disable the detector at runtime. The cycle
867864
detector is considered an optional component; though it is included by default,

Doc/reference/datamodel.rst

+7-5
Original file line numberDiff line numberDiff line change
@@ -1133,8 +1133,10 @@ Basic customization
11331133
reference to the object on the stack frame that raised an unhandled
11341134
exception in interactive mode (the traceback stored in
11351135
``sys.last_traceback`` keeps the stack frame alive). The first situation
1136-
can only be remedied by explicitly breaking the cycles; the latter two
1137-
situations can be resolved by storing ``None`` in ``sys.last_traceback``.
1136+
can only be remedied by explicitly breaking the cycles; the second can be
1137+
resolved by freeing the reference to the traceback object when it is no
1138+
longer useful, and the third can be resolved by storing ``None`` in
1139+
``sys.last_traceback``.
11381140
Circular references which are garbage are detected and cleaned up when
11391141
the cyclic garbage collector is enabled (it's on by default). Refer to the
11401142
documentation for the :mod:`gc` module for more information about this
@@ -1556,9 +1558,9 @@ saved because *__dict__* is not created for each instance.
15561558
.. data:: object.__slots__
15571559

15581560
This class variable can be assigned a string, iterable, or sequence of
1559-
strings with variable names used by instances. If defined in a
1560-
class, *__slots__* reserves space for the declared variables and prevents the
1561-
automatic creation of *__dict__* and *__weakref__* for each instance.
1561+
strings with variable names used by instances. *__slots__* reserves space
1562+
for the declared variables and prevents the automatic creation of *__dict__*
1563+
and *__weakref__* for each instance.
15621564

15631565

15641566
Notes on using *__slots__*

Doc/reference/executionmodel.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ specified in the statement refer to the binding of that name in the top-level
111111
namespace. Names are resolved in the top-level namespace by searching the
112112
global namespace, i.e. the namespace of the module containing the code block,
113113
and the builtins namespace, the namespace of the module :mod:`builtins`. The
114-
global namespace is searched first. If the name is not found there, the builtins
115-
namespace is searched. The global statement must precede all uses of the name.
114+
global namespace is searched first. If the name is not found there, the
115+
builtins namespace is searched. The :keyword:`global` statement must precede
116+
all uses of the name.
116117

117118
.. XXX document "nonlocal" semantics here
118119

Doc/reference/expressions.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ slice list contains no proper slice).
619619
single: stop (slice object attribute)
620620
single: step (slice object attribute)
621621

622-
The semantics for a slicing are as follows. The primary must evaluate to a
623-
mapping object, and it is indexed (using the same :meth:`__getitem__` method as
622+
The semantics for a slicing are as follows. The primary is indexed (using the
623+
same :meth:`__getitem__` method as
624624
normal subscription) with a key that is constructed from the slice list, as
625625
follows. If the slice list contains at least one comma, the key is a tuple
626626
containing the conversion of the slice items; otherwise, the conversion of the

Doc/reference/lexical_analysis.rst

+19-19
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ instance of the :class:`bytes` type instead of the :class:`str` type. They
443443
may only contain ASCII characters; bytes with a numeric value of 128 or greater
444444
must be expressed with escapes.
445445

446-
As of Python 3.3 it is possible again to prefix unicode strings with a
446+
As of Python 3.3 it is possible again to prefix string literals with a
447447
``u`` prefix to simplify maintenance of dual 2.x and 3.x codebases.
448448

449449
Both string and bytes literals may optionally be prefixed with a letter ``'r'``
@@ -453,24 +453,24 @@ escapes in raw strings are not treated specially. Given that Python 2.x's raw
453453
unicode literals behave differently than Python 3.x's the ``'ur'`` syntax
454454
is not supported.
455455

456-
.. versionadded:: 3.3
457-
The ``'rb'`` prefix of raw bytes literals has been added as a synonym
458-
of ``'br'``.
456+
.. versionadded:: 3.3
457+
The ``'rb'`` prefix of raw bytes literals has been added as a synonym
458+
of ``'br'``.
459459

460-
.. versionadded:: 3.3
461-
Support for the unicode legacy literal (``u'value'``) was reintroduced
462-
to simplify the maintenance of dual Python 2.x and 3.x codebases.
463-
See :pep:`414` for more information.
460+
.. versionadded:: 3.3
461+
Support for the unicode legacy literal (``u'value'``) was reintroduced
462+
to simplify the maintenance of dual Python 2.x and 3.x codebases.
463+
See :pep:`414` for more information.
464464

465-
In triple-quoted strings, unescaped newlines and quotes are allowed (and are
466-
retained), except that three unescaped quotes in a row terminate the string. (A
467-
"quote" is the character used to open the string, i.e. either ``'`` or ``"``.)
465+
In triple-quoted literals, unescaped newlines and quotes are allowed (and are
466+
retained), except that three unescaped quotes in a row terminate the literal. (A
467+
"quote" is the character used to open the literal, i.e. either ``'`` or ``"``.)
468468

469469
.. index:: physical line, escape sequence, Standard C, C
470470

471-
Unless an ``'r'`` or ``'R'`` prefix is present, escape sequences in strings are
472-
interpreted according to rules similar to those used by Standard C. The
473-
recognized escape sequences are:
471+
Unless an ``'r'`` or ``'R'`` prefix is present, escape sequences in string and
472+
bytes literals are interpreted according to rules similar to those used by
473+
Standard C. The recognized escape sequences are:
474474

475475
+-----------------+---------------------------------+-------+
476476
| Escape Sequence | Meaning | Notes |
@@ -547,20 +547,20 @@ Notes:
547547
.. index:: unrecognized escape sequence
548548

549549
Unlike Standard C, all unrecognized escape sequences are left in the string
550-
unchanged, i.e., *the backslash is left in the string*. (This behavior is
550+
unchanged, i.e., *the backslash is left in the result*. (This behavior is
551551
useful when debugging: if an escape sequence is mistyped, the resulting output
552552
is more easily recognized as broken.) It is also important to note that the
553553
escape sequences only recognized in string literals fall into the category of
554554
unrecognized escapes for bytes literals.
555555

556-
Even in a raw string, string quotes can be escaped with a backslash, but the
557-
backslash remains in the string; for example, ``r"\""`` is a valid string
556+
Even in a raw literal, quotes can be escaped with a backslash, but the
557+
backslash remains in the result; for example, ``r"\""`` is a valid string
558558
literal consisting of two characters: a backslash and a double quote; ``r"\"``
559559
is not a valid string literal (even a raw string cannot end in an odd number of
560-
backslashes). Specifically, *a raw string cannot end in a single backslash*
560+
backslashes). Specifically, *a raw literal cannot end in a single backslash*
561561
(since the backslash would escape the following quote character). Note also
562562
that a single backslash followed by a newline is interpreted as those two
563-
characters as part of the string, *not* as a line continuation.
563+
characters as part of the literal, *not* as a line continuation.
564564

565565

566566
.. _string-catenation:

Doc/reference/simple_stmts.rst

+5-6
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,8 @@ printed::
548548
RuntimeError: Something bad happened
549549

550550
A similar mechanism works implicitly if an exception is raised inside an
551-
exception handler: the previous exception is then attached as the new
552-
exception's :attr:`__context__` attribute::
551+
exception handler or a :keyword:`finally` clause: the previous exception is then
552+
attached as the new exception's :attr:`__context__` attribute::
553553

554554
>>> try:
555555
... print(1 / 0)
@@ -731,10 +731,9 @@ in the module's namespace which do not begin with an underscore character
731731
to avoid accidentally exporting items that are not part of the API (such as
732732
library modules which were imported and used within the module).
733733

734-
The :keyword:`from` form with ``*`` may only occur in a module scope. The wild
735-
card form of import --- ``from module import *`` --- is only allowed at the
736-
module level. Attempting to use it in class or function definitions will raise
737-
a :exc:`SyntaxError`.
734+
The wild card form of import --- ``from module import *`` --- is only allowed at
735+
the module level. Attempting to use it in class or function definitions will
736+
raise a :exc:`SyntaxError`.
738737

739738
.. index::
740739
single: relative; import

Doc/reference/toplevel_components.rst

+1-11
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,10 @@ Expression input
9797
================
9898

9999
.. index:: single: input
100-
101100
.. index:: builtin: eval
102101

103-
There are two forms of expression input. Both ignore leading whitespace. The
102+
:func:`eval` is used for expression input. It ignores leading whitespace. The
104103
string argument to :func:`eval` must have the following form:
105104

106105
.. productionlist::
107106
eval_input: `expression_list` NEWLINE*
108-
109-
.. index::
110-
object: file
111-
single: input; raw
112-
single: readline() (file method)
113-
114-
Note: to read 'raw' input line without interpretation, you can use the
115-
:meth:`readline` method of file objects, including ``sys.stdin``.
116-

0 commit comments

Comments
 (0)