Skip to content

Commit e66fb14

Browse files
committed
Merge branch 'main' into handle_count
2 parents e6200f0 + 40f7fbf commit e66fb14

48 files changed

Lines changed: 1265 additions & 224 deletions

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/type.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ but need extra remarks for use as slots:
699699
700700
.. soft-deprecated:: 3.15
701701
702-
When not targetting older Python versions, pefer :c:macro:`!Py_tp_bases`.
702+
When not targeting older Python versions, prefer :c:macro:`!Py_tp_bases`.
703703
704704
The following slots do not correspond to public fields in the
705705
underlying structures:

Doc/library/ast.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ Control flow
13661366

13671367
``try`` blocks which are followed by ``except*`` clauses. The attributes are the
13681368
same as for :class:`Try` but the :class:`ExceptHandler` nodes in ``handlers``
1369-
are interpreted as ``except*`` blocks rather then ``except``.
1369+
are interpreted as ``except*`` blocks rather than ``except``.
13701370

13711371
.. doctest::
13721372

Doc/library/compression.zstd.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ Advanced parameter control
503503
The :meth:`~.bounds` method can be used on any attribute to get the valid
504504
values for that parameter.
505505

506-
Parameters are optional; any omitted parameter will have it's value selected
506+
Parameters are optional; any omitted parameter will have its value selected
507507
automatically.
508508

509509
Example getting the lower and upper bound of :attr:`~.compression_level`::
@@ -732,7 +732,7 @@ Advanced parameter control
732732

733733
An :class:`~enum.IntEnum` containing the advanced decompression parameter
734734
keys that can be used when decompressing data. Parameters are optional; any
735-
omitted parameter will have it's value selected automatically.
735+
omitted parameter will have its value selected automatically.
736736

737737
The :meth:`~.bounds` method can be used on any attribute to get the valid
738738
values for that parameter.

Doc/library/functions.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,6 +2179,11 @@ are always available. They are listed here in alphabetical order.
21792179
in the same way that keywords in a class
21802180
definition (besides *metaclass*) would.
21812181

2182+
Unlike a :keyword:`class` statement, the three argument form does not
2183+
call the metaclass ``__prepare__`` method (see :ref:`prepare`). Use
2184+
:func:`types.new_class` to dynamically create a class using the
2185+
appropriate metaclass.
2186+
21822187
See also :ref:`class-customization`.
21832188

21842189
.. versionchanged:: 3.6

Doc/library/lzma.rst

Lines changed: 105 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -152,35 +152,14 @@ Compressing and decompressing data in memory
152152
:func:`compress`.
153153

154154
The *format* argument specifies what container format should be used.
155-
Possible values are:
156-
157-
* :const:`FORMAT_XZ`: The ``.xz`` container format.
158-
This is the default format.
159-
160-
* :const:`FORMAT_ALONE`: The legacy ``.lzma`` container format.
161-
This format is more limited than ``.xz`` -- it does not support integrity
162-
checks or multiple filters.
163-
164-
* :const:`FORMAT_RAW`: A raw data stream, not using any container format.
165-
This format specifier does not support integrity checks, and requires that
166-
you always specify a custom filter chain (for both compression and
167-
decompression). Additionally, data compressed in this manner cannot be
168-
decompressed using :const:`FORMAT_AUTO` (see :class:`LZMADecompressor`).
155+
Possible values are :const:`FORMAT_XZ` (the default),
156+
:const:`FORMAT_ALONE` and :const:`FORMAT_RAW`.
169157

170158
The *check* argument specifies the type of integrity check to include in the
171159
compressed data. This check is used when decompressing, to ensure that the
172-
data has not been corrupted. Possible values are:
173-
174-
* :const:`CHECK_NONE`: No integrity check.
175-
This is the default (and the only acceptable value) for
176-
:const:`FORMAT_ALONE` and :const:`FORMAT_RAW`.
177-
178-
* :const:`CHECK_CRC32`: 32-bit Cyclic Redundancy Check.
179-
180-
* :const:`CHECK_CRC64`: 64-bit Cyclic Redundancy Check.
181-
This is the default for :const:`FORMAT_XZ`.
182-
183-
* :const:`CHECK_SHA256`: 256-bit Secure Hash Algorithm.
160+
data has not been corrupted. Possible values are :const:`CHECK_NONE`,
161+
:const:`CHECK_CRC32`, :const:`CHECK_CRC64` (the default for
162+
:const:`FORMAT_XZ`) and :const:`CHECK_SHA256`.
184163

185164
If the specified check is not supported, an :class:`LZMAError` is raised.
186165

@@ -412,6 +391,106 @@ These filters support one option, ``start_offset``. This specifies the address
412391
that should be mapped to the beginning of the input data. The default is 0.
413392

414393

394+
Constants
395+
---------
396+
397+
The following module-level constants are provided for use as the *format*,
398+
*check*, *preset* and *filters* arguments of the classes and functions above.
399+
400+
Container formats:
401+
402+
.. data:: FORMAT_XZ
403+
404+
The ``.xz`` container format.
405+
406+
.. data:: FORMAT_ALONE
407+
408+
The legacy ``.lzma`` container format. This format is more limited than
409+
``.xz`` -- it does not support integrity checks or multiple filters.
410+
411+
.. data:: FORMAT_RAW
412+
413+
A raw data stream, not using any container format. This format specifier
414+
does not support integrity checks, and requires that you always specify a
415+
custom filter chain (for both compression and decompression). Additionally,
416+
data compressed in this manner cannot be decompressed using
417+
:const:`FORMAT_AUTO`.
418+
419+
.. data:: FORMAT_AUTO
420+
421+
Used for decompression only. The container format is detected
422+
automatically, so that both ``.xz`` and ``.lzma`` files can be decompressed.
423+
424+
Integrity checks:
425+
426+
.. data:: CHECK_NONE
427+
428+
No integrity check. This is the default (and the only acceptable value) for
429+
:const:`FORMAT_ALONE` and :const:`FORMAT_RAW`.
430+
431+
.. data:: CHECK_CRC32
432+
433+
A 32-bit Cyclic Redundancy Check.
434+
435+
.. data:: CHECK_CRC64
436+
437+
A 64-bit Cyclic Redundancy Check. This is the default for
438+
:const:`FORMAT_XZ`.
439+
440+
.. data:: CHECK_SHA256
441+
442+
A 256-bit Secure Hash Algorithm.
443+
444+
.. data:: CHECK_UNKNOWN
445+
446+
The integrity check used by a stream could not yet be determined. This may
447+
be the value of the :attr:`LZMADecompressor.check` attribute until enough of
448+
the input has been decoded.
449+
450+
.. data:: CHECK_ID_MAX
451+
452+
The largest supported integrity-check ID.
453+
454+
Compression presets:
455+
456+
.. data:: PRESET_DEFAULT
457+
458+
The default compression preset, equivalent to preset level ``6``.
459+
460+
.. data:: PRESET_EXTREME
461+
462+
A flag that may be bitwise OR-ed with a preset level (``0`` to ``9``) to
463+
select a slower but more thorough variant of that preset.
464+
465+
Filter IDs and options:
466+
467+
.. data:: FILTER_LZMA1
468+
FILTER_LZMA2
469+
470+
The LZMA1 and LZMA2 compression filters. :const:`FILTER_LZMA1` is for use
471+
with :const:`FORMAT_ALONE`, while :const:`FILTER_LZMA2` is for use with
472+
:const:`FORMAT_XZ` and :const:`FORMAT_RAW`.
473+
474+
.. data:: FILTER_DELTA
475+
476+
The delta filter.
477+
478+
.. data:: MODE_FAST
479+
MODE_NORMAL
480+
481+
Compression modes that may be used as the ``mode`` option of a filter
482+
specifier (see :ref:`filter-chain-specs`).
483+
484+
.. data:: MF_HC3
485+
MF_HC4
486+
MF_BT2
487+
MF_BT3
488+
MF_BT4
489+
490+
Match finders that may be used as the ``mf`` option of a filter specifier
491+
(see :ref:`filter-chain-specs`).
492+
493+
415494
Examples
416495
--------
417496

Doc/library/sys.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only
21352135
returned by the :func:`open` function. Their parameters are chosen as
21362136
follows:
21372137

2138-
* The encoding and error handling are is initialized from
2138+
* The encoding and error handling are initialized from
21392139
:c:member:`PyConfig.stdio_encoding` and :c:member:`PyConfig.stdio_errors`.
21402140

21412141
On Windows, UTF-8 is used for the console device. Non-character

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Doc/library/email.parser.rst
1212
Doc/library/importlib.rst
1313
Doc/library/logging.config.rst
1414
Doc/library/logging.handlers.rst
15-
Doc/library/lzma.rst
1615
Doc/library/mmap.rst
1716
Doc/library/multiprocessing.rst
1817
Doc/library/optparse.rst

Doc/whatsnew/3.14.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3312,6 +3312,16 @@ Changes in the Python API
33123312
This temporary change affects other threads.
33133313
(Contributed by Serhiy Storchaka in :gh:`69998`.)
33143314

3315+
* :func:`pickle.dump` and :func:`pickle.dumps` now raise
3316+
:exc:`~pickle.PicklingError` for some failures that previously raised
3317+
:exc:`AttributeError`, :exc:`ImportError`, :exc:`ValueError`,
3318+
:exc:`UnicodeEncodeError` or :exc:`!PicklingError`,
3319+
depending on the implementation
3320+
(for example, pickling a local object, or an object whose module cannot be imported).
3321+
The original exception is chained to the :exc:`!PicklingError`.
3322+
Code that caught these exceptions should also catch :exc:`!PicklingError`.
3323+
(Contributed by Serhiy Storchaka in :gh:`122311`.)
3324+
33153325
* :class:`types.UnionType` is now an alias for :class:`typing.Union`,
33163326
causing changes in some behaviors.
33173327
See :ref:`above <whatsnew314-typing-union>` for more details.

Include/py_curses.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343
# define PDC_NCMOUSE
4444
#endif
4545

46+
/* On Solaris/illumos, the SVr4 <curses.h> does "typedef char bool;", which
47+
clashes with C's bool from <stdbool.h>. Define _BOOL to suppress it, and
48+
include <stdbool.h> for the bool the header then needs. ncurses ignores
49+
_BOOL. */
50+
#if defined(__sun) && !defined(_BOOL)
51+
# include <stdbool.h>
52+
# define _BOOL
53+
#endif
54+
4655
#if defined(HAVE_NCURSESW_NCURSES_H)
4756
# include <ncursesw/ncurses.h>
4857
#elif defined(HAVE_NCURSESW_CURSES_H)

Lib/asyncio/base_subprocess.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def __init__(self, loop, protocol, args, shell,
2626
self._pending_calls = collections.deque()
2727
self._pipes = {}
2828
self._finished = False
29-
self._pipes_connected = False
3029

3130
if stdin == subprocess.PIPE:
3231
self._pipes[0] = None
@@ -214,7 +213,6 @@ async def _connect_pipes(self, waiter):
214213
else:
215214
if waiter is not None and not waiter.cancelled():
216215
waiter.set_result(None)
217-
self._pipes_connected = True
218216

219217
def _call(self, cb, *data):
220218
if self._pending_calls is not None:
@@ -235,6 +233,7 @@ def _process_exited(self, returncode):
235233
if self._loop.get_debug():
236234
logger.info('%r exited with return code %r', self, returncode)
237235
self._returncode = returncode
236+
238237
if self._proc.returncode is None:
239238
# asyncio uses a child watcher: copy the status into the Popen
240239
# object. On Python 3.6, it is required to avoid a ResourceWarning.
@@ -243,6 +242,13 @@ def _process_exited(self, returncode):
243242

244243
self._try_finish()
245244

245+
# gh-119710: Wake up futures waiting for wait() as soon as the process
246+
# exits.
247+
for waiter in self._exit_waiters:
248+
if not waiter.done():
249+
waiter.set_result(returncode)
250+
self._exit_waiters = None
251+
246252
async def _wait(self):
247253
"""Wait until the process exit and return the process return code.
248254
@@ -258,15 +264,7 @@ def _try_finish(self):
258264
assert not self._finished
259265
if self._returncode is None:
260266
return
261-
if not self._pipes_connected:
262-
# self._pipes_connected can be False if not all pipes were connected
263-
# because either the process failed to start or the self._connect_pipes task
264-
# got cancelled. In this broken state we consider all pipes disconnected and
265-
# to avoid hanging forever in self._wait as otherwise _exit_waiters
266-
# would never be woken up, we wake them up here.
267-
for waiter in self._exit_waiters:
268-
if not waiter.done():
269-
waiter.set_result(self._returncode)
267+
270268
if all(p is not None and p.disconnected
271269
for p in self._pipes.values()):
272270
self._finished = True
@@ -276,11 +274,6 @@ def _call_connection_lost(self, exc):
276274
try:
277275
self._protocol.connection_lost(exc)
278276
finally:
279-
# wake up futures waiting for wait()
280-
for waiter in self._exit_waiters:
281-
if not waiter.done():
282-
waiter.set_result(self._returncode)
283-
self._exit_waiters = None
284277
self._loop = None
285278
self._proc = None
286279
self._protocol = None

0 commit comments

Comments
 (0)