Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e4196d3

Browse files
committed
#22613: fix several factual errors in builtin docs (thanks Jacques Ducasse)
1 parent f0d2ed7 commit e4196d3

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

Doc/library/exceptions.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class or one of its subclasses, and not from :exc:`BaseException`. More
3434
information on defining exceptions is available in the Python Tutorial under
3535
:ref:`tut-userexceptions`.
3636

37-
When raising (or re-raising) an exception in an :keyword:`except` clause
37+
When raising (or re-raising) an exception in an :keyword:`except` or
38+
:keyword:`finally` clause
3839
:attr:`__context__` is automatically set to the last exception caught; if the
3940
new exception is not handled the traceback that is eventually displayed will
4041
include the originating exception(s) and the final exception.

Doc/library/functions.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ are always available. They are listed here in alphabetical order.
210210
The optional arguments *flags* and *dont_inherit* control which future
211211
statements (see :pep:`236`) affect the compilation of *source*. If neither
212212
is present (or both are zero) the code is compiled with those future
213-
statements that are in effect in the code that is calling compile. If the
213+
statements that are in effect in the code that is calling :func:`compile`. If the
214214
*flags* argument is given and *dont_inherit* is not (or is zero) then the
215215
future statements specified by the *flags* argument are used in addition to
216216
those that would be used anyway. If *dont_inherit* is a non-zero integer then
@@ -231,6 +231,9 @@ are always available. They are listed here in alphabetical order.
231231
This function raises :exc:`SyntaxError` if the compiled source is invalid,
232232
and :exc:`TypeError` if the source contains null bytes.
233233

234+
If you want to parse Python code into its AST representation, see
235+
:func:`ast.parse`.
236+
234237
.. note::
235238

236239
When compiling a string with multi-line code in ``'single'`` or
@@ -539,7 +542,7 @@ are always available. They are listed here in alphabetical order.
539542
effect as calling :func:`str(value) <str>`.
540543

541544
A call to ``format(value, format_spec)`` is translated to
542-
``type(value).__format__(format_spec)`` which bypasses the instance
545+
``type(value).__format__(value, format_spec)`` which bypasses the instance
543546
dictionary when searching for the value's :meth:`__format__` method. A
544547
:exc:`TypeError` exception is raised if the method search reaches
545548
:mod:`object` and the *format_spec* is non-empty, or if either the

Doc/library/stdtypes.rst

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ the same rule. [2]_ The constructors :func:`int`, :func:`float`, and
269269
:func:`complex` can be used to produce numbers of a specific type.
270270

271271
All numeric types (except complex) support the following operations, sorted by
272-
ascending priority (operations in the same box have the same priority; all
273-
numeric operations have a higher priority than comparison operations):
272+
ascending priority (all numeric operations have a higher priority than
273+
comparison operations):
274274

275275
+---------------------+---------------------------------+---------+--------------------+
276276
| Operation | Result | Notes | Full documentation |
@@ -404,8 +404,7 @@ The priorities of the binary bitwise operations are all lower than the numeric
404404
operations and higher than the comparisons; the unary operation ``~`` has the
405405
same priority as the other unary numeric operations (``+`` and ``-``).
406406

407-
This table lists the bitwise operations sorted in ascending priority
408-
(operations in the same box have the same priority):
407+
This table lists the bitwise operations sorted in ascending priority:
409408

410409
+------------+--------------------------------+----------+
411410
| Operation | Result | Notes |
@@ -444,7 +443,7 @@ Additional Methods on Integer Types
444443
-----------------------------------
445444

446445
The int type implements the :class:`numbers.Integral` :term:`abstract base
447-
class`. In addition, it provides one more method:
446+
class`. In addition, it provides a few more methods:
448447

449448
.. method:: int.bit_length()
450449

@@ -820,10 +819,10 @@ both mutable and immutable. The :class:`collections.abc.Sequence` ABC is
820819
provided to make it easier to correctly implement these operations on
821820
custom sequence types.
822821

823-
This table lists the sequence operations sorted in ascending priority
824-
(operations in the same box have the same priority). In the table, *s* and *t*
825-
are sequences of the same type, *n*, *i*, *j* and *k* are integers and *x* is
826-
an arbitrary object that meets any type and value restrictions imposed by *s*.
822+
This table lists the sequence operations sorted in ascending priority. In the
823+
table, *s* and *t* are sequences of the same type, *n*, *i*, *j* and *k* are
824+
integers and *x* is an arbitrary object that meets any type and value
825+
restrictions imposed by *s*.
827826

828827
The ``in`` and ``not in`` operations have the same priorities as the
829828
comparison operations. The ``+`` (concatenation) and ``*`` (repetition)
@@ -4006,8 +4005,8 @@ before the statement body is executed and exited when the statement ends:
40064005
The exception passed in should never be reraised explicitly - instead, this
40074006
method should return a false value to indicate that the method completed
40084007
successfully and does not want to suppress the raised exception. This allows
4009-
context management code (such as ``contextlib.nested``) to easily detect whether
4010-
or not an :meth:`__exit__` method has actually failed.
4008+
context management code to easily detect whether or not an :meth:`__exit__`
4009+
method has actually failed.
40114010

40124011
Python defines several context managers to support easy thread synchronisation,
40134012
prompt closure of files or other objects, and simpler manipulation of the active

0 commit comments

Comments
 (0)