Commit 6ca59afa authored by Georg Brandl's avatar Georg Brandl

#22613: fix several factual errors in builtin docs (thanks Jacques Ducasse)

parent 6517052c
...@@ -34,7 +34,8 @@ class or one of its subclasses, and not from :exc:`BaseException`. More ...@@ -34,7 +34,8 @@ class or one of its subclasses, and not from :exc:`BaseException`. More
information on defining exceptions is available in the Python Tutorial under information on defining exceptions is available in the Python Tutorial under
:ref:`tut-userexceptions`. :ref:`tut-userexceptions`.
When raising (or re-raising) an exception in an :keyword:`except` clause When raising (or re-raising) an exception in an :keyword:`except` or
:keyword:`finally` clause
:attr:`__context__` is automatically set to the last exception caught; if the :attr:`__context__` is automatically set to the last exception caught; if the
new exception is not handled the traceback that is eventually displayed will new exception is not handled the traceback that is eventually displayed will
include the originating exception(s) and the final exception. include the originating exception(s) and the final exception.
......
...@@ -210,7 +210,7 @@ are always available. They are listed here in alphabetical order. ...@@ -210,7 +210,7 @@ are always available. They are listed here in alphabetical order.
The optional arguments *flags* and *dont_inherit* control which future The optional arguments *flags* and *dont_inherit* control which future
statements (see :pep:`236`) affect the compilation of *source*. If neither statements (see :pep:`236`) affect the compilation of *source*. If neither
is present (or both are zero) the code is compiled with those future is present (or both are zero) the code is compiled with those future
statements that are in effect in the code that is calling compile. If the statements that are in effect in the code that is calling :func:`compile`. If the
*flags* argument is given and *dont_inherit* is not (or is zero) then the *flags* argument is given and *dont_inherit* is not (or is zero) then the
future statements specified by the *flags* argument are used in addition to future statements specified by the *flags* argument are used in addition to
those that would be used anyway. If *dont_inherit* is a non-zero integer then 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. ...@@ -231,6 +231,9 @@ are always available. They are listed here in alphabetical order.
This function raises :exc:`SyntaxError` if the compiled source is invalid, This function raises :exc:`SyntaxError` if the compiled source is invalid,
and :exc:`TypeError` if the source contains null bytes. and :exc:`TypeError` if the source contains null bytes.
If you want to parse Python code into its AST representation, see
:func:`ast.parse`.
.. note:: .. note::
When compiling a string with multi-line code in ``'single'`` or 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. ...@@ -539,7 +542,7 @@ are always available. They are listed here in alphabetical order.
effect as calling :func:`str(value) <str>`. effect as calling :func:`str(value) <str>`.
A call to ``format(value, format_spec)`` is translated to A call to ``format(value, format_spec)`` is translated to
``type(value).__format__(format_spec)`` which bypasses the instance ``type(value).__format__(value, format_spec)`` which bypasses the instance
dictionary when searching for the value's :meth:`__format__` method. A dictionary when searching for the value's :meth:`__format__` method. A
:exc:`TypeError` exception is raised if the method search reaches :exc:`TypeError` exception is raised if the method search reaches
:mod:`object` and the *format_spec* is non-empty, or if either the :mod:`object` and the *format_spec* is non-empty, or if either the
......
...@@ -269,8 +269,8 @@ the same rule. [2]_ The constructors :func:`int`, :func:`float`, and ...@@ -269,8 +269,8 @@ the same rule. [2]_ The constructors :func:`int`, :func:`float`, and
:func:`complex` can be used to produce numbers of a specific type. :func:`complex` can be used to produce numbers of a specific type.
All numeric types (except complex) support the following operations, sorted by All numeric types (except complex) support the following operations, sorted by
ascending priority (operations in the same box have the same priority; all ascending priority (all numeric operations have a higher priority than
numeric operations have a higher priority than comparison operations): comparison operations):
+---------------------+---------------------------------+---------+--------------------+ +---------------------+---------------------------------+---------+--------------------+
| Operation | Result | Notes | Full documentation | | Operation | Result | Notes | Full documentation |
...@@ -404,8 +404,7 @@ The priorities of the binary bitwise operations are all lower than the numeric ...@@ -404,8 +404,7 @@ The priorities of the binary bitwise operations are all lower than the numeric
operations and higher than the comparisons; the unary operation ``~`` has the operations and higher than the comparisons; the unary operation ``~`` has the
same priority as the other unary numeric operations (``+`` and ``-``). same priority as the other unary numeric operations (``+`` and ``-``).
This table lists the bitwise operations sorted in ascending priority This table lists the bitwise operations sorted in ascending priority:
(operations in the same box have the same priority):
+------------+--------------------------------+----------+ +------------+--------------------------------+----------+
| Operation | Result | Notes | | Operation | Result | Notes |
...@@ -444,7 +443,7 @@ Additional Methods on Integer Types ...@@ -444,7 +443,7 @@ Additional Methods on Integer Types
----------------------------------- -----------------------------------
The int type implements the :class:`numbers.Integral` :term:`abstract base The int type implements the :class:`numbers.Integral` :term:`abstract base
class`. In addition, it provides one more method: class`. In addition, it provides a few more methods:
.. method:: int.bit_length() .. method:: int.bit_length()
...@@ -820,10 +819,10 @@ both mutable and immutable. The :class:`collections.abc.Sequence` ABC is ...@@ -820,10 +819,10 @@ both mutable and immutable. The :class:`collections.abc.Sequence` ABC is
provided to make it easier to correctly implement these operations on provided to make it easier to correctly implement these operations on
custom sequence types. custom sequence types.
This table lists the sequence operations sorted in ascending priority This table lists the sequence operations sorted in ascending priority. In the
(operations in the same box have the same priority). In the table, *s* and *t* table, *s* and *t* are sequences of the same type, *n*, *i*, *j* and *k* are
are sequences of the same type, *n*, *i*, *j* and *k* are integers and *x* is integers and *x* is an arbitrary object that meets any type and value
an arbitrary object that meets any type and value restrictions imposed by *s*. restrictions imposed by *s*.
The ``in`` and ``not in`` operations have the same priorities as the The ``in`` and ``not in`` operations have the same priorities as the
comparison operations. The ``+`` (concatenation) and ``*`` (repetition) comparison operations. The ``+`` (concatenation) and ``*`` (repetition)
...@@ -4006,8 +4005,8 @@ before the statement body is executed and exited when the statement ends: ...@@ -4006,8 +4005,8 @@ before the statement body is executed and exited when the statement ends:
The exception passed in should never be reraised explicitly - instead, this The exception passed in should never be reraised explicitly - instead, this
method should return a false value to indicate that the method completed method should return a false value to indicate that the method completed
successfully and does not want to suppress the raised exception. This allows successfully and does not want to suppress the raised exception. This allows
context management code (such as ``contextlib.nested``) to easily detect whether context management code to easily detect whether or not an :meth:`__exit__`
or not an :meth:`__exit__` method has actually failed. method has actually failed.
Python defines several context managers to support easy thread synchronisation, Python defines several context managers to support easy thread synchronisation,
prompt closure of files or other objects, and simpler manipulation of the active prompt closure of files or other objects, and simpler manipulation of the active
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment