Skip to content

Commit cb6468d

Browse files
authored
Merge pull request #512 from python/main
Sync Fork from Upstream Repo
2 parents 7549a92 + c45fa1a commit cb6468d

97 files changed

Lines changed: 9304 additions & 6477 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Doc/c-api/memory.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ Customize Memory Allocators
490490
Debug hooks on the Python memory allocators
491491
===========================================
492492
493-
When :ref:`Python is built is debug mode <debug-build>`, the
493+
When :ref:`Python is built in debug mode <debug-build>`, the
494494
:c:func:`PyMem_SetupDebugHooks` function is called at the :ref:`Python
495495
preinitialization <c-preinit>` to setup debug hooks on Python memory allocators
496496
to detect memory errors.

Doc/library/asyncio-eventloop.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,16 +1132,12 @@ Executing code in thread or process pools
11321132
.. method:: loop.set_default_executor(executor)
11331133

11341134
Set *executor* as the default executor used by :meth:`run_in_executor`.
1135-
*executor* should be an instance of
1135+
*executor* must be an instance of
11361136
:class:`~concurrent.futures.ThreadPoolExecutor`.
11371137

1138-
.. deprecated:: 3.8
1139-
Using an executor that is not an instance of
1140-
:class:`~concurrent.futures.ThreadPoolExecutor` is deprecated and
1141-
will trigger an error in Python 3.9.
1142-
1143-
*executor* must be an instance of
1144-
:class:`concurrent.futures.ThreadPoolExecutor`.
1138+
.. versionchanged:: 3.11
1139+
*executor* must be an instance of
1140+
:class:`~concurrent.futures.ThreadPoolExecutor`.
11451141

11461142

11471143
Error Handling API

Doc/library/asyncio-task.rst

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ other coroutines::
148148
* a *coroutine object*: an object returned by calling a
149149
*coroutine function*.
150150

151-
asyncio also supports legacy :ref:`generator-based
152-
<asyncio_generator_based_coro>` coroutines.
153-
154151

155152
.. rubric:: Tasks
156153

@@ -1042,60 +1039,3 @@ Task Object
10421039
in the :func:`repr` output of a task object.
10431040

10441041
.. versionadded:: 3.8
1045-
1046-
1047-
.. _asyncio_generator_based_coro:
1048-
1049-
Generator-based Coroutines
1050-
==========================
1051-
1052-
.. note::
1053-
1054-
Support for generator-based coroutines is **deprecated** and
1055-
is scheduled for removal in Python 3.10.
1056-
1057-
Generator-based coroutines predate async/await syntax. They are
1058-
Python generators that use ``yield from`` expressions to await
1059-
on Futures and other coroutines.
1060-
1061-
Generator-based coroutines should be decorated with
1062-
:func:`@asyncio.coroutine <asyncio.coroutine>`, although this is not
1063-
enforced.
1064-
1065-
1066-
.. decorator:: coroutine
1067-
1068-
Decorator to mark generator-based coroutines.
1069-
1070-
This decorator enables legacy generator-based coroutines to be
1071-
compatible with async/await code::
1072-
1073-
@asyncio.coroutine
1074-
def old_style_coroutine():
1075-
yield from asyncio.sleep(1)
1076-
1077-
async def main():
1078-
await old_style_coroutine()
1079-
1080-
This decorator should not be used for :keyword:`async def`
1081-
coroutines.
1082-
1083-
.. deprecated-removed:: 3.8 3.10
1084-
1085-
Use :keyword:`async def` instead.
1086-
1087-
.. function:: iscoroutine(obj)
1088-
1089-
Return ``True`` if *obj* is a :ref:`coroutine object <coroutine>`.
1090-
1091-
This method is different from :func:`inspect.iscoroutine` because
1092-
it returns ``True`` for generator-based coroutines.
1093-
1094-
.. function:: iscoroutinefunction(func)
1095-
1096-
Return ``True`` if *func* is a :ref:`coroutine function
1097-
<coroutine>`.
1098-
1099-
This method is different from :func:`inspect.iscoroutinefunction`
1100-
because it returns ``True`` for generator-based coroutine functions
1101-
decorated with :func:`@coroutine <coroutine>`.

Doc/library/collections.abc.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ ABC Inherits from Abstract Methods Mixin
198198

199199
.. note::
200200
In CPython, generator-based coroutines (generators decorated with
201-
:func:`types.coroutine` or :func:`asyncio.coroutine`) are
201+
:func:`types.coroutine`) are
202202
*awaitables*, even though they do not have an :meth:`__await__` method.
203203
Using ``isinstance(gencoro, Awaitable)`` for them will return ``False``.
204204
Use :func:`inspect.isawaitable` to detect them.
@@ -216,7 +216,7 @@ ABC Inherits from Abstract Methods Mixin
216216

217217
.. note::
218218
In CPython, generator-based coroutines (generators decorated with
219-
:func:`types.coroutine` or :func:`asyncio.coroutine`) are
219+
:func:`types.coroutine`) are
220220
*awaitables*, even though they do not have an :meth:`__await__` method.
221221
Using ``isinstance(gencoro, Coroutine)`` for them will return ``False``.
222222
Use :func:`inspect.isawaitable` to detect them.

Doc/library/contextlib.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,9 @@ Functions and classes provided:
515515
These context managers may suppress exceptions just as they normally
516516
would if used directly as part of a :keyword:`with` statement.
517517

518-
... versionchanged:: 3.11
519-
Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm*
520-
is not a context manager.
518+
.. versionchanged:: 3.11
519+
Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm*
520+
is not a context manager.
521521

522522
.. method:: push(exit)
523523

@@ -589,9 +589,9 @@ Functions and classes provided:
589589
Similar to :meth:`enter_context` but expects an asynchronous context
590590
manager.
591591

592-
... versionchanged:: 3.11
593-
Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm*
594-
is not an asynchronous context manager.
592+
.. versionchanged:: 3.11
593+
Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm*
594+
is not an asynchronous context manager.
595595

596596
.. method:: push_async_exit(exit)
597597

Doc/library/marshal.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ The module defines these functions:
6666
The *version* argument indicates the data format that ``dump`` should use
6767
(see below).
6868

69+
.. audit-event:: marshal.dumps value,version marshal.dump
70+
6971

7072
.. function:: load(file)
7173

@@ -74,11 +76,18 @@ The module defines these functions:
7476
format), raise :exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. The
7577
file must be a readable :term:`binary file`.
7678

79+
.. audit-event:: marshal.load "" marshal.load
80+
7781
.. note::
7882

7983
If an object containing an unsupported type was marshalled with :func:`dump`,
8084
:func:`load` will substitute ``None`` for the unmarshallable type.
8185

86+
.. versionchanged:: 3.10
87+
88+
This call used to raise a ``code.__new__`` audit event for each code object. Now
89+
it raises a single ``marshal.load`` event for the entire load operation.
90+
8291

8392
.. function:: dumps(value[, version])
8493

@@ -89,13 +98,22 @@ The module defines these functions:
8998
The *version* argument indicates the data format that ``dumps`` should use
9099
(see below).
91100

101+
.. audit-event:: marshal.dumps value,version marshal.dump
102+
92103

93104
.. function:: loads(bytes)
94105

95106
Convert the :term:`bytes-like object` to a value. If no valid value is found, raise
96107
:exc:`EOFError`, :exc:`ValueError` or :exc:`TypeError`. Extra bytes in the
97108
input are ignored.
98109

110+
.. audit-event:: marshal.loads bytes marshal.load
111+
112+
.. versionchanged:: 3.10
113+
114+
This call used to raise a ``code.__new__`` audit event for each code object. Now
115+
it raises a single ``marshal.loads`` event for the entire load operation.
116+
99117

100118
In addition, the following constants are defined:
101119

Doc/library/pprint.rst

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,36 @@ The :mod:`pprint` module defines one class:
4242
compact=False, sort_dicts=True, underscore_numbers=False)
4343

4444
Construct a :class:`PrettyPrinter` instance. This constructor understands
45-
several keyword parameters. An output stream may be set using the *stream*
46-
keyword; the only method used on the stream object is the file protocol's
47-
:meth:`write` method. If not specified, the :class:`PrettyPrinter` adopts
48-
``sys.stdout``. The
49-
amount of indentation added for each recursive level is specified by *indent*;
50-
the default is one. Other values can cause output to look a little odd, but can
51-
make nesting easier to spot. The number of levels which may be printed is
52-
controlled by *depth*; if the data structure being printed is too deep, the next
53-
contained level is replaced by ``...``. By default, there is no constraint on
54-
the depth of the objects being formatted. The desired output width is
55-
constrained using the *width* parameter; the default is 80 characters. If a
56-
structure cannot be formatted within the constrained width, a best effort will
57-
be made. If *compact* is false (the default) each item of a long sequence
58-
will be formatted on a separate line. If *compact* is true, as many items
59-
as will fit within the *width* will be formatted on each output line. If
60-
*sort_dicts* is true (the default), dictionaries will be formatted with their
61-
keys sorted, otherwise they will display in insertion order. If
62-
*underscore_numbers* is true, integers will be formatted with the
45+
several keyword parameters.
46+
47+
*stream* (default ``sys.stdout``) is a :term:`file-like object` to
48+
which the output will be written by calling its :meth:`write` method.
49+
50+
Other values configure the manner in which nesting of complex data
51+
structures is displayed.
52+
53+
*indent* (default 1) specifies the amount of indentation added for
54+
each nesting level.
55+
56+
*depth* controls the number of nesting levels which may be printed; if
57+
the data structure being printed is too deep, the next contained level
58+
is replaced by ``...``. By default, there is no constraint on the
59+
depth of the objects being formatted.
60+
61+
*width* (default 80) specifies the desired maximum number of characters per
62+
line in the output. If a structure cannot be formatted within the width
63+
constraint, a best effort will be made.
64+
65+
*compact* impacts the way that long sequences (lists, tuples, sets, etc)
66+
are formatted. If *compact* is false (the default) then each item of a
67+
sequence will be formatted on a separate line. If *compact* is true, as
68+
many items as will fit within the *width* will be formatted on each output
69+
line.
70+
71+
If *sort_dicts* is true (the default), dictionaries will be formatted with
72+
their keys sorted, otherwise they will display in insertion order.
73+
74+
If *underscore_numbers* is true, integers will be formatted with the
6375
``_`` character for a thousands separator, otherwise underscores are not
6476
displayed (the default).
6577

Doc/library/traceback.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,37 +447,42 @@ The output for the example would look similar to this:
447447
*** print_tb:
448448
File "<doctest...>", line 10, in <module>
449449
lumberjack()
450+
^^^^^^^^^^^^
450451
*** print_exception:
451452
Traceback (most recent call last):
452453
File "<doctest...>", line 10, in <module>
453454
lumberjack()
455+
^^^^^^^^^^^^
454456
File "<doctest...>", line 4, in lumberjack
455457
bright_side_of_death()
458+
^^^^^^^^^^^^^^^^^^^^^^
456459
IndexError: tuple index out of range
457460
*** print_exc:
458461
Traceback (most recent call last):
459462
File "<doctest...>", line 10, in <module>
460463
lumberjack()
464+
^^^^^^^^^^^^
461465
File "<doctest...>", line 4, in lumberjack
462466
bright_side_of_death()
467+
^^^^^^^^^^^^^^^^^^^^^^
463468
IndexError: tuple index out of range
464469
*** format_exc, first and last line:
465470
Traceback (most recent call last):
466471
IndexError: tuple index out of range
467472
*** format_exception:
468473
['Traceback (most recent call last):\n',
469-
' File "<doctest...>", line 10, in <module>\n lumberjack()\n',
470-
' File "<doctest...>", line 4, in lumberjack\n bright_side_of_death()\n',
471-
' File "<doctest...>", line 7, in bright_side_of_death\n return tuple()[0]\n',
474+
' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n ^^^^^^^^^^^^\n',
475+
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n ^^^^^^^^^^^^^^^^^^^^^^\n',
476+
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ^^^^^^^^^^\n',
472477
'IndexError: tuple index out of range\n']
473478
*** extract_tb:
474479
[<FrameSummary file <doctest...>, line 10 in <module>>,
475480
<FrameSummary file <doctest...>, line 4 in lumberjack>,
476481
<FrameSummary file <doctest...>, line 7 in bright_side_of_death>]
477482
*** format_tb:
478-
[' File "<doctest...>", line 10, in <module>\n lumberjack()\n',
479-
' File "<doctest...>", line 4, in lumberjack\n bright_side_of_death()\n',
480-
' File "<doctest...>", line 7, in bright_side_of_death\n return tuple()[0]\n']
483+
[' File "<doctest default[0]>", line 10, in <module>\n lumberjack()\n ^^^^^^^^^^^^\n',
484+
' File "<doctest default[0]>", line 4, in lumberjack\n bright_side_of_death()\n ^^^^^^^^^^^^^^^^^^^^^^\n',
485+
' File "<doctest default[0]>", line 7, in bright_side_of_death\n return tuple()[0]\n ^^^^^^^^^^\n']
481486
*** tb_lineno: 10
482487

483488

Doc/library/typing.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,8 +1232,13 @@ These are not used in annotations. They are building blocks for creating generic
12321232

12331233
.. note::
12341234

1235-
:func:`runtime_checkable` will check only the presence of the required methods,
1236-
not their type signatures.
1235+
:func:`runtime_checkable` will check only the presence of the required
1236+
methods, not their type signatures. For example, :class:`ssl.SSLObject`
1237+
is a class, therefore it passes an :func:`issubclass`
1238+
check against :data:`Callable`. However, the
1239+
:meth:`ssl.SSLObject.__init__` method exists only to raise a
1240+
:exc:`TypeError` with a more informative message, therefore making
1241+
it impossible to call (instantiate) :class:`ssl.SSLObject`.
12371242

12381243
.. versionadded:: 3.8
12391244

Doc/library/unittest.mock.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ the *new_callable* argument to :func:`patch`.
262262
this is a new Mock (created on first access). See the
263263
:attr:`return_value` attribute.
264264

265-
* *unsafe*: By default, accessing any attribute with name starting with
265+
* *unsafe*: By default, accessing any attribute whose name starts with
266266
*assert*, *assret*, *asert*, *aseert* or *assrt* will raise an
267267
:exc:`AttributeError`. Passing ``unsafe=True`` will allow access to
268268
these attributes.

0 commit comments

Comments
 (0)