Skip to content

Latest commit

 

History

History
2611 lines (1887 loc) · 62.6 KB

3.15.1.rst

File metadata and controls

2611 lines (1887 loc) · 62.6 KB

Bump the version of :pypi:`pip` bundled in :mod:`ensurepip` to version 26.2.2.

:mod:`mimetypes` no longer reads the files listed in :data:`mimetypes.knownfiles` by default on Windows, and uses only the registry.

Update bundled libexpat to version 2.9.0.

Avoid a crash if allocation fails while creating a :class:`string.templatelib.Template` iterator.

Propagate errors during generic class construction and avoid a crash after failed generic alias substitution.

Raise :exc:`OverflowError` when the absolute value of a dynamic printf-style formatting width is too large.

Fix a reference leak in :func:`gc.get_objects` and :func:`gc.get_referrers` when an internal allocation fails in the free-threaded build.

Fix memory leaks during interpreter startup when a path configuration file is empty or too large, or when an audit hook rejects a command.

Avoid a crash when an interpreter configuration string cannot be encoded as UTF-8.

Preserve the original :exc:`SyntaxError` if allocating optional error metadata fails.

Avoid a crash if formatting an integer with the c presentation type runs out of memory.

Avoid a crash when a module filename cannot be encoded as UTF-8.

On FreeBSD, call pthread_attr_get_np() to get the stack size (and guard size) of the current thread. Patch by Victor Stinner.

Fix bug where compiler did not set the right exception handler for some jump instructions.

Report the correct exception if looking up :meth:`~object.__bytes__` raises an exception while performing %-formatting of :class:`bytes`.

Add dynamic detection of stack sizes on Android, allowing safer deep recursion.

Fix a crash when walking a very long chain of lazy import placeholders, as created by an aliased dotted import such as lazy import a.b.c as d. :exc:`RecursionError` is now raised instead.

Fix a crash in a debug build when copying an empty :class:`dict` fails with :exc:`MemoryError`. Patch by Christian Aurich Zanettini Martins.

Fix a use-after-free in :mod:`asyncio` task bookkeeping when a finalizer creates a task during thread shutdown.

Reset the warnings lock in the child after :func:`os.fork`, before clearing other threads' states, to avoid deadlocks when their finalizers issue warnings. Preserve the lock's recursion depth if the forking thread owns it.

Reduce C stack usage of _PyModule_IsPossiblyShadowing, which could potentially cause stack overflows during module attribute access while deeply recursing in agressively optimized builds.

Fix a crash in :meth:`bytes.join` and :meth:`bytearray.join` in the :term:`free-threaded build` when another thread concurrently mutates the list being joined. Patch by Christian Aurich Zanettini Martins.

Fix module-level :meth:`~module.__getattr__` being called before a module's own lazy imports were resolved, which allowed it to shadow them.

Fix a crash when a :ref:`lazy import <lazy-imports>` is declared or resolved by a finalizer running during interpreter shutdown.

Skip the array reallocation when shrinking a small :class:`list`. Patch by Donghee Na.

:meth:`bytes.fromhex` and :meth:`bytearray.fromhex`: Fix uninitialized memory read. Patch by Victor Stinner.

Fix crashes and debug-build assertion failures in the :term:`free-threaded build` when iterating over a split dictionary while another thread deletes entries or clears it. Publish insertion-order updates atomically so readers cannot observe an increased size before the corresponding order entry is initialized.

del list[index] now triggers shrinking the list's internal array.

Fix the PowerSort mask calculation in :meth:`list.sort` for very large lists.

Fix missing :mod:`sys.monitoring` INSTRUCTION events when a LINE callback returns :data:`sys.monitoring.DISABLE`.

Fix :class:`bytearray` constructor: do not use a bytes object if its hash value is already computed. Patch by Cody Maloney and Victor Stinner.

Fix a JIT crash when a class is instantiated with their default arguments

Fix the JIT optimizer folding a builtin name to a constant taken from the interpreter's builtins dictionary even when the running function uses a different __builtins__ mapping, such as one created with vars(builtins).copy(). The optimizer now only folds when the function's builtins is the interpreter's, and the folded constant is guarded at runtime so that another function sharing the same code object but a different builtins mapping does not use it.

If :meth:`bytearray.resize` or :meth:`bytearray.take_bytes` fails, leave the :class:`bytearray` unchanged, instead of clearing it. Patch by Victor Stinner.

Fix a crash when compiling deeply nested inlined list, set, or dict comprehensions. A :exc:`SyntaxError` is now raised when the nesting exceeds the compiler's static block limit.

Fix standard library discovery in virtual environments created from a Python executable symlink located outside its base installation.

Fix cleanup on error in compiler_set_qualname. Previously it was called in _PyCompile_EnterScope, after the scope had been entered, and this was not reversed in case of an error.

Fix missing PyRefTracer_DESTROY events for trashcan deferred objects. Patch by Donghee Na.

Fix a crash in :c:func:`PyErr_GivenExceptionMatches` when evaluating deeply nested exception tuples. The recursion is now bounded, and exceeding the limit is reported as an unraisable exception.

Fix a JIT bug where the side exit taken when a virtual iterator is exhausted left a stale value on the stack, so the tier one interpreter resumed with corrupted state and yield from raised :exc:`AttributeError` instead of finishing normally.

Fix a crash when thread state creation fails before the thread state is fully initialized.

Fix :mod:`marshal` so that a frozendict referenced more than once in the serialized data round-trips correctly, instead of failing to load with :exc:`ValueError`. Patch by tonghuaroot.

Fix a data race on thread handle identifiers when _thread._shutdown() runs concurrently with the startup of non-daemon threads in the :term:`free-threaded build`.

Reduced lock contention during LOAD_GLOBAL bytecode specialization under free threading.

Fix an out-of-bounds write in :meth:`bytearray.extend` when the bytearray is resized while the argument's :meth:`~object.__buffer__` is being acquired, for example by another thread. Patch by tonghuaroot.

Fixed a crash in :func:`marshal.loads` when an allocation failed while loading a reference-tracked dictionary; it now raises :exc:`MemoryError`.

Fix a free-threaded stop-the-world fairness issue that could starve a thread reattaching after being suspended while detached.

Fix a Use-After-Free race condition in subtype_getweakref() during concurrent weakref creation and destruction in the free-threading build.

Fix race conditions in invoke_gc_callback iterating gc.callbacks in free-threading mode.

Fix :term:`REPL` completions inserted incorrectly when there was spaces in import statements.

Ignore :func:`pdb.set_trace` when called directly at the :mod:`pdb` prompt.

Fix a crash in :func:`syslog.openlog` under the free-threaded build when :data:`sys.argv` is modified concurrently.

Fix a crash in :mod:`hashlib` when the OpenSSL routine used by :meth:`hash.update() <hashlib.hash.update>` or by hash object constructors fails on data larger than 2048 bytes. Patch by Bénédikt Tran.

Fix a crash in :mod:`hmac` when the OpenSSL routine used by :meth:`hmac.HMAC.update` or by :func:`hmac.new` fails on data larger than 2048 bytes. Patch by Bénédikt Tran.

Fix the error handling of the HACL* routine used by :func:`hmac.new` and :meth:`hmac.HMAC.update`. If the maximum input length of the underlying hash function is exceeded, an :exc:`OverflowError` is now raised on all builds, instead of crashing on DEBUG builds and being silently ignored otherwise. Code correctness. Realistically this can only happen at implausible sizes. Patch by Bénédikt Tran.

Fix copying :class:`collections.deque` subclasses with a large maximum length.

Allow cyclic garbage collection to reclaim group records returned by :mod:`grp`.

Fix :class:`io.BytesIO` reads into overlapping views of the same buffer.

Avoid a crash when memory allocation fails while creating a :class:`collections.OrderedDict` items iterator.

Avoid reading past the end of an encoding name when the surrogatepass error handler receives a truncated UTF-16 or UTF-32 name.

Fix incorrect :mod:`ctypes` scalar values after :func:`ctypes.resize` enlarges the object.

Fix a memory leak when Unicode normalization cannot grow its temporary buffer.

Fix resource leaks in :mod:`ssl` when certificate conversion or key log setup fails.

Fix :meth:`bdb.Bdb.clear_all_file_breaks` leaving breakpoints behind when multiple breakpoints are set on the same line.

Fix python -m asyncio ps, pstree and async-aware :mod:`profiling.sampling` stacks stopping at asynchronous generators. Patch by Timofei Ivankov.

Fix a ThreadSanitizer data race on the static cache in normalize_century() of the datetime module under the free-threaded build.

Report the correct exception if looking up __name__ raises an exception when calling :func:`repr` on a :class:`weakref.ref`.

Prevent input calls in PyREPL from modifying readline history.

Restore the previous behaviour of :meth:`http.client.HTTPConnection.set_tunnel` where header values that are not strings (such as :const:`None`, :class:`int` or other objects) are converted with :class:`str` instead of raising :exc:`AttributeError` when the request is sent.

Fix :func:`marshal.dumps` raising :exc:`MemoryError` for a set or frozenset containing several complex NaNs, which also made it impossible to write a :file:`.pyc` file for source code containing such a constant.

Fix a crash in :func:`marshal.dumps` and :func:`marshal.dump` when a set is modified while its elements are serialized, for example by the :meth:`~object.__buffer__` method of one of its elements. :exc:`RuntimeError` is now raised.

Fix reference cycles in :meth:`asyncio.loop.create_connection` and :meth:`asyncio.loop.start_tls` after a failed TLS handshake. Patch by Timofei Ivankov.

Fixed error in :mod:`email` new policies where header folding failed to detect the need to re-quote text obtained from encoded words in certain cases.

Fix crash when calling :func:`syslog.syslog` while a subinterpreter in another thread calls :func:`syslog.openlog` or :func:`syslog.closelog`.

:func:`~dataclasses.dataclass` no longer fails when a string annotation names a :ref:`lazy import <lazy-imports>` that cannot be resolved, matching the behavior for non-string annotations.

Make :func:`os.strerror` thread-safe: use the reentrant strerror_r() function if available. Patch by Victor Stinner.

Fix macOS runtime section lookup for remote debugging when virtual memory region sizes differ from Mach-O segment file sizes.

Fix deep flamegraph exports on platforms with small C stacks by falling back to the Python JSON encoder when the C encoder runs out of stack space.

Wait for Windows threads to finish suspending before reading target memory in the sampling profiler's blocking mode. Resume the target if waiting for suspension fails.

Fix :func:`asyncio.shield` reporting an exception from the inner future through the loop exception handler as soon as it completes after the shield was cancelled, even when the exception is retrieved afterwards. The exception is now reported only if it is never retrieved, as with any other future.

Fix :mod:`profiling.sampling` exception mode discarding samples for code running inside an except block in a generator or coroutine. The remote debugger now follows tstate->exc_info and its previous_item chain instead of only reading the embedded exc_state, matching the exception that :func:`sys.exception` reports.

Fix :func:`turtle.undo` after :func:`turtle.teleport` and after an exception in :func:`turtle.circle`, :func:`turtle.dot` or :func:`turtle.write`. Fix :func:`turtle.stamp`, :func:`turtle.clearstamp`, :func:`turtle.clear` and :func:`turtle.reset` when the undo buffer is disabled.

Fix :mod:`profiling.sampling` not adding the directory containing the profiled script to :data:`sys.path`, which prevented the script from importing modules placed next to it. The script's directory is now added, matching the behavior of python script.py.

Fix :mod:`profiling.sampling` showing a single frame for a task whose coroutine recurses. Patch by Timofei Ivankov.

Fix :attr:`zlib.Decompress.unconsumed_tail` duplicating :attr:`~zlib.Decompress.unused_data` after end of stream when max_length was used.

Fix :func:`asyncio.as_completed` to continue yielding every awaitable after a pending iteration step is cancelled.

Fix :func:`unittest.mock.patch` with autospec, spec, or spec_set when used with lazy-imported objects.

Fix :mod:`tkinter` on macOS: creating a :class:`~tkinter.Tk` instance no longer replaces the Python handlers of SIGINT, SIGHUP and SIGTERM with Tk's handler which exits the process, so Ctrl-C raises :exc:`KeyboardInterrupt` again.

Fix a crash when a weak-reference callback is attached to a :class:`typing.ParamSpecArgs` or :class:`typing.ParamSpecKwargs` instance.

:meth:`code.InteractiveInterpreter.runsource` and the REPL now report any exception raised by compiling the source, such as :exc:`MemoryError` or :exc:`RecursionError` for too deeply nested source, instead of propagating it or printing a traceback of the REPL internals.

Fix :mod:`gettext` plural form selection when the Plural-Forms expression combines the unary ! operator with a binary operator, for example !n + 1 or 2 * !n. The latter raised :exc:`SyntaxError`.

Fix the Python implementation of :class:`xml.etree.ElementTree.XMLParser`: the doctype() method of the target is now called for a document type declaration without an external identifier, like <!DOCTYPE html>, as in the C implementation.

Fix a use-after-free in :class:`io.TextIOWrapper` when a call to the underlying buffer reentrantly detaches it. Patched by Shamil Abdulaev.

:class:`io.BytesIO` is no longer closed on write() and truncate() failure (:exc:`MemoryError`). Patch by Victor Stinner.

Fix an out-of-bounds read in the hz incremental decoder when the input ends with ~.

Fix :func:`readline.write_history_file` and :func:`readline.append_history_file` producing a history file that :func:`readline.read_history_file` could not load when a limit was set with :func:`readline.set_history_length` and Python was built against libedit. This works around NetBSD PR 60322.

:mod:`linecache` can now read the source of a module that was imported from a zip archive on :data:`sys.path` when given only the file name, as :mod:`pdb`, :mod:`warnings` and :mod:`doctest` do.

Preserve the position and contents of :class:`io.BytesIO` when :meth:`!BytesIO.__init__` fails because a buffer is exported.

Fix :func:`tkinter.font.nametofont` and the :class:`tkinter.font.Font` constructor for a font name returned by Tk as a Tcl object, for example by :meth:`ttk.Style.lookup() <tkinter.ttk.Style.lookup>`.

Fix a crash in :mod:`curses.panel` when the finalizer of a panel's user pointer runs while the panel is being deallocated. The panel is now taken off the panel stack before its user pointer is dropped.

Fix :mod:`asyncio` on Windows: closing a :class:`~asyncio.DatagramTransport` under :class:`~asyncio.ProactorEventLoop` while datagrams were still queued, or while an in-flight write failed right as close() was draining the buffer, could strand the queued data and never call connection_lost(), hanging the close indefinitely.

Fix a :exc:`UnicodeEncodeError` crash in the sampling profiler's collapsed-stack export (--collapsed) when a sampled frame's function or file name contains non-ASCII or surrogate-escaped characters. The output file is now written as UTF-8.

Fix :class:`xml.sax.saxutils.XMLGenerator`: the namespace URI is now escaped in the namespace declaration. Previously a URI containing &, < or a quote character produced a document which cannot be parsed.

:mod:`xml.etree.ElementTree` now accepts input larger than 2 GiB in the C implementation. The data is fed to Expat in chunks, as :mod:`xml.parsers.expat` already did, instead of raising :exc:`OverflowError`.

Fix :func:`xml.etree.ElementTree.parse` with a text file or other source of :class:`str` data in the C implementation. The encoding declared in the document was applied to the already decoded text, which produced mojibake. It is now ignored, as when parsing with :meth:`!XMLParser.feed` or :func:`~xml.etree.ElementTree.fromstring`.

Fix :func:`!nturl2path.pathname2url` and :func:`!nturl2path.url2pathname`: the filesystem encoding and error handler are now used for percent-encoding and decoding, as in :mod:`urllib.request`. Previously paths containing surrogate characters raised :exc:`UnicodeEncodeError`.

Fix :class:`asyncio.ProactorEventLoop` UDP transports so that a write error no longer strands a paused protocol: the write loop is now rescheduled when data remains buffered, and the protocol is resumed when the buffer has drained.

:mod:`xml.dom` and :mod:`xml.etree.ElementTree` no longer treat characters which are not white space in XML (such as U+00A0) as white space. Previously they could be lost in :func:`~xml.etree.ElementTree.indent`, :func:`~xml.etree.ElementTree.canonicalize` with strip_text=True, and when parsing with the whitespace-in-element-content feature turned off.

:func:`zipapp.create_archive` now correctly sets the executable bit on the target archive when copying a zipapp where the target is a path-like object.

Fix the sampling profiler's flamegraph export so that profiling a deeply recursive program no longer fails with :exc:`RecursionError` instead of producing a flamegraph. Patch by tonghuaroot.

The pure Python implementation of :meth:`queue.SimpleQueue.get` now ignores timeout when block is false, matching the documented behavior and the C implementation. It previously raised :exc:`ValueError`.

Fix matching of a negated character set in a bytes pattern compiled with both :const:`re.IGNORECASE` and :const:`re.LOCALE`. The case closure is now applied to the members of the set, so that [^bc] no longer matches b'B'.

:func:`zlib.adler32_combine` and :func:`zlib.crc32_combine` now raise :exc:`ValueError` if the len2 argument is negative, instead of returning rubbish or hanging indefinitely, respectively.

:mod:`ssl`: A failed assignment or deletion of the _msg_callback attribute of :class:`ssl.SSLContext` no longer removes the current callback. Deleting it now raises :exc:`AttributeError` instead of :exc:`TypeError`.

Calling :meth:`zlib.Decompress.flush` on invalid compressed data now raises :exc:`zlib.error` instead of being silently ignored.

:mod:`sqlite3`: Disallow removing the row_factory attribute of a cursor to prevent a crash on a query.

Fix a crash in the free-threaded build when deleting the :attr:`!contents` attribute of a :mod:`ctypes` pointer.

Fix :attr:`sqlite3.Cursor.arraysize` being set to 0 if the assigned value is too large. The attribute is now left unchanged if the assignment fails.

Fix crashes in :class:`sqlite3.Connection` when deleting the :attr:`~sqlite3.Connection.autocommit` attribute or setting it to an integer which does not fit in C :c:expr:`long`. Both now raise an exception.

Fix a crash when deleting the keylog_filename attribute of :class:`ssl.SSLContext`. It now raises :exc:`AttributeError`.

Fix error handling in the :mod:`zoneinfo` accelerator module when a transition index is -1 or a TZ string's __bool__ raises.

Fix :func:`concurrent.interpreters.list_all`. It failed if an interpreter was destroyed during the call, in particular by a garbage collection which finalized the object owning the last reference to it.

Fix :func:`asyncio.start_server` when a plain-function client_connected_cb raises: the error is now reported like the coroutine case and the transport is closed, instead of leaving the connection open forever (which also made :meth:`asyncio.Server.wait_closed` hang).

:mod:`hmac`: ensure that HMAC objects are properly initialized to prevent rare crashes on allocation failures. Patch by Bénédikt Tran.

:mod:`hashlib`: Fix data races when accessing :attr:`~hashlib.hash.digest_size` and :attr:`~hashlib.hash.block_size` on SHA-3 objects. Patch by Bénédikt Tran.

:mod:`!_blake2`: Ensure that BLAKE-2 objects are correctly initialized before being tracked by the garbage collector. Patch by Bénédikt Tran.

:mod:`ssl`: prevent a crash in :meth:`~ssl.SSLSocket.group` for session-less objects on OpenSSL 3.2 and later. Patch by Bénédikt Tran.

Add a sequence counter to GC statistics to prevent :mod:`!_remote_debugging` returning inconsistent snapshots caused by non-atomic reads. Patch by Maurycy Pawłowski-Wieroński.

:mod:`multiprocessing`'s default start method is now :ref:`"spawn" <multiprocessing-start-methods>` instead of "forkserver" when there is no writable temporary directory, such as on a read-only file system. Previously starting a process failed with an :exc:`OSError` there. Patch by Bénédikt Tran.

Fix a regression in :mod:`imaplib` introduced in the fix for :gh:`63121`: refreshing the capabilities after a successful :meth:`~imaplib.IMAP4.login` or :meth:`~imaplib.IMAP4.authenticate` consumed the CAPABILITY response, so it could no longer be read with :meth:`~imaplib.IMAP4.response`.

Fix crashes when deleting an attribute whose setter is generated by Argument Clinic and is not prepared for deletion, among them :attr:`frame.f_trace_opcodes` and the context, owner and session attributes of _ssl._SSLSocket. Deleting such attribute now raises :exc:`AttributeError`.

Fix :class:`sqlite3.Blob` slices with a negative step. Reading or writing such a slice raised :exc:`SystemError`. It now raises :exc:`ValueError`.

Fix error handling in :func:`socket.gethostbyaddr` and :func:`socket.gethostbyname_ex` when hostname resolution fails.

Make sure that the pure Python fallback of :func:`hmac.digest` rejects keys that are neither :class:`bytes` or :class:`bytearray`. Previously, an :exc:`AttributeError` was raised instead of :exc:`TypeError`. Patch by Bénédikt Tran.

Fix :func:`os.path.realpath` on Windows: the unresolved part of the path is now appended, not joined, so a file name which looks like a drive (e.g. spam:eggs) no longer discards the resolved part. A path relative to another drive is now resolved against the root directory of that drive.

Fix :func:`os.path.realpath` on Windows: the \\?\ prefix is no longer stripped from a volume GUID path, which made the result invalid.

Fix :func:`os.stat` on Windows: trailing dots and spaces, which are ignored by the operating system, are no longer taken into account when the execute permissions are guessed from the file extension.

:func:`warnings.warn_explicit` now displays the source line taken from the loader of the module whose globals are passed as module_globals. It also no longer raises :exc:`IndexError` if lineno is out of the range of the module source.

:func:`warnings.warn_explicit` no longer emits a spurious :exc:`DeprecationWarning` or raises :exc:`ImportError` when it is called with the globals of the :mod:`__main__` module.

:program:`python -m inspect --details` no longer fails with :exc:`UnicodeEncodeError` if the path of the module contains characters unencodable in the encoding of :data:`sys.stdout`. Such characters are now escaped with backslashes.

Fix :mod:`pydoc` for modules whose path contains undecodable bytes. :func:`!pydoc.writedoc` and the pydoc HTTP server no longer fail with :exc:`UnicodeEncodeError`: the file URL is now percent-encoded using the filesystem encoding, and characters unencodable in the generated HTML page are escaped with backslashes.

Fix :meth:`curses.window.instr` returning one character too few when the :mod:`curses` module is built against a curses library that counts the terminator in the requested length, such as the NetBSD one.

Fix :func:`copy.deepcopy` so that an object whose deep copy is None is still memoized. Patch by tonghuaroot.

Fixed data-race when calling :meth:`io.TextIOBase.detach` in :term:`free-threaded build`.

:class:`logging.FileHandler` and :class:`logging.handlers.WatchedFileHandler` now honor :data:`logging.raiseExceptions` for errors that occur while opening the file, like for other errors during logging.

:class:`logging.handlers.SysLogHandler` no longer fails if the address cannot be resolved when the handler is created. The address is resolved again when a record is emitted.

Calling :func:`str` on a :exc:`subprocess.CalledProcessError` no longer raises :exc:`TypeError` when its :attr:`!returncode` is not an integer, such as None.

Fix the sampling profiler dropping entire samples when a non-fatal read fails; frames now keep any readable metadata, and long funcnames and filenames are truncated instead. Patch by Maurycy Pawłowski-Wieroński.

:meth:`!concurrent.interpreters.Queue.get` and :meth:`!concurrent.interpreters.Queue.put` now compute their timeout deadline from :func:`time.monotonic` instead of the wall clock, so adjusting the system clock during the call no longer makes them over- or under-wait.

Stop normalizing differential flamegraph baselines to the duration of the current profile.

Fix :exc:`OSError` when importing :mod:`ctypes` from a statically linked interpreter.

Skip non-regular files in the profiling.sampling heatmap exporter instead of reading them unconditionally. Patch by tonghuaroot.

Fix duplicate :exc:`SyntaxWarning` messages when importing source modules from ZIP archives. :meth:`zipimport.zipimporter.get_filename`, and therefore :meth:`~zipimport.zipimporter.find_spec`, no longer compile source modules. A :exc:`SyntaxError` in a zipped source module is now raised when the module is executed rather than when it is found, matching the behavior of filesystem-based loaders.

Fix a crash in the ISO-2022 decoders when decoding a byte after an unknown charset designation is set via the decoder's setstate method. Patch by tonghuaroot.

Fix a crash in the C implementation of :meth:`io.TextIOWrapper.tell` when the decoder's getstate method triggers a reentrant seek, or when another thread seeks the same stream concurrently. Patch by tonghuaroot.

Fix a crash when the same :func:`os.scandir` iterator is used concurrently from multiple threads. It no longer releases the directory handle while another thread is reading from it. Sharing an iterator between threads remains subject to race conditions: which entries each thread receives is unspecified.

Make frame, coroutine and task-waiter walks iterative and bounded, avoiding potential hangs and stack overflows. Fix asyncio task inspection when awaited-by sets contain removed entries. Patch by Maurycy Pawłowski-Wieroński.

:mod:`hashlib`: fix a crash arising from a race condition when looking up an OpenSSL hash algorithm by name the first time. Patch by Bénédikt Tran.

Fix profiling.sampling --binary leaving unreadable profile files when the binary format reaches a size limit. Preserve collected samples when the writer can still finalize safely. Patch by Maurycy Pawłowski-Wieroński.

Fix quadratic replay time in the :mod:`profiling.sampling` binary reader when a profile's run-length-encoded samples alternate thread status.

Fix a crash caused by failing to set :exc:`MemoryError` on allocation failure when passing :class:`ctypes.Structure` or :class:`ctypes.Union` instances by value to ctypes foreign functions.

Fix :func:`annotationlib.type_repr` returning a string such as None.list.append for bound built-in methods, whose __module__ is None. It now returns the qualified name, as it already did for other builtins.

Fix :exc:`TypeError` when formatting a :exc:`SyntaxError` raised with :data:`NotImplemented` as its argument, which caused unexpected REPL exit and IDLE Shell restart.

Fix the :mod:`pdb` until command not stepping over a list comprehension when a breakpoint is set on it. Patch by tonghuaroot.

Fix the pure-Python implementations of :meth:`datetime.date.fromisoformat`, :meth:`datetime.time.fromisoformat` and :meth:`datetime.datetime.fromisoformat` silently accepting some malformed ISO 8601 strings, such as non-ASCII digits or a sign in a fixed-width field (for example '2020+12' or '20201212T0102٣٤'). Each field is now required to be exactly N ASCII digits, matching the C implementation.

Fix :func:`tarfile.open` in streaming write mode (w|gz) raising :exc:`struct.error` when given an mtime outside the range of the gzip header's 32-bit timestamp field. Out-of-range values are now stored as 0, matching :mod:`gzip`.

Fix :mod:`mimetypes` initialization from MIME map files containing invalid UTF-8 bytes.

Fix race conditions when re-initializing a :class:`io.TextIOWrapper` object.

Fix :func:`plistlib.dumps` and :func:`plistlib.dump` so that skipkeys=True together with sort_keys=True correctly drops non-string keys when the dictionary contains a mix of string and non-string keys. Previously the sort ran before the filter and raised :exc:`TypeError`.

:mod:`concurrent.interpreters`: fix a crash when internal cross-interpreter channel ends have incorrect channel IDs. Patch by Bénédikt Tran.

Fix a crash in asyncio.Future iterator when send() is called after throw() or close().

Fix crash in :class:`io.TextIOWrapper` when reentrant :meth:`io.TextIOBase.detach` is called reentrantly from the underlying buffer.

Improve exception handling when computing suggestions in traceback.py. This fixes a bug that could cause PyREPL to exit unexpectedly.

A bug in :func:`!doctest._SpoofOut.truncate` was causing None to be passed to :func:`!StringIO.seek` when no size was given. A simple fix skips the seek call when no size is given so the buffer can be truncated from the current position.

:meth:`http.cookiejar.FileCookieJar.load` now checks the first, format signature line in a case-insensitive manner. Patch by Ashley Harvey.

Creating a new :mod:`turtle` screen after the previous one was closed no longer raises turtle.Terminator on the first turtle command.

The exploded attribute of :class:`ipaddress.IPv6Address` and :class:`ipaddress.IPv6Interface` now supports addresses with a scope ID (link-local addresses). Previously the former raised :exc:`~ipaddress.AddressValueError` and the latter omitted the scope ID.

Fix :mod:`tarfile` reading an archive with a GNU sparse 1.0 member whose size is set in the pax extended header. The offset of the next header was computed from the offset of the data, which is already past the sparse map, and from the size of the member, which can be the apparent size of the sparse file. All following members were unreachable.

:class:`http.cookiejar.MozillaCookieJar` now reads session cookies written by curl and Wget, which use 0 in the expiration time field. Contributed by Jérémie Detrey.

Document the 'w' type code in the :class:`array.array` docstring, so that it lists the same type codes as :data:`array.typecodes` and the :mod:`array` module documentation.

Added docstrings to abstract ctypes.

Restore the recursion limit after the free-threading recursion-limit race test to avoid failures in subsequent tests run in the same process.

The iOS testbed no longer gathers simulator diagnostics when a test run fails.

In regrtest, only consider that a test leaks if all test runs leak at least one file descriptor. For example, ignore "[0, 1, -1] file descriptors, sum=0" deltas, instead of reporting a leak. Patch by Victor Stinner.

Enable limited C API tests on Free Threading in test_cext and test_cppext: test the :c:macro:`Py_TARGET_ABI3T` macro. Patch by Victor Stinner.

A test decorated with :func:`~test.support.bigmemtest` now runs in a subprocess if it really allocates the memory it asks for (that is, if the -M option is used), so that the memory it uses and the address space it fragments are released when it ends. A dummy run stays in the process. The separate memory watchdog process is no longer needed: the parent process watches the memory usage of the subprocess.

Fix :func:`!test.support.subTests` for asynchronous test methods. They were wrapped in a synchronous function, which discarded the coroutine without awaiting it, so the test silently did not run at all.

The list of tests which altered the execution environment now includes the reasons why the environment was considered altered, for example an unraisable exception or a modified :data:`sys.path`. The final result no longer repeats the same state twice (like ENV CHANGED then ENV CHANGED).

Add test.support.run_with_limited_c_stack() and use it in tests that exhaust the C stack with a fixed number of recursive calls, so that their outcome no longer depends on the C stack size.

Fix the check that disables PR_SET_VMA_ANON_NAME on musl libc: it tested an unset variable, so it never had any effect and the build could fail with a redefinition of struct prctl_mm_map.

Fix the libpython.static path in PEP 739 build-details.json, which pointed to a file that is not installed when building with :option:`--enable-shared`, and no longer list a static library for framework builds, which do not install one.

The version string reported by sys.version no longer carries a spurious -dirty suffix when CPython is built out-of-tree from a clean git checkout: the build stamp now checks the source tree instead of the build directory.

Fix the :file:`Modules/Setup` entry for the :mod:`!_zstd` module by adding missing source files.

Fix the link of Programs/_freeze_module when extension modules are built in (MODULE_BUILDTYPE=static) and the test modules are enabled: Modules/getpath_noop.c now defines _Py_Get_Getpath_CodeObject(), which _testinternalcapi uses.

Fix curses detection when a curses library is already in LIBS. Patch by Shamil Abdulaev.

Fix a key handle leak in :func:`winreg.CreateKey`, :func:`winreg.CreateKeyEx` and :func:`winreg.OpenKey` when the winreg.OpenKey/result audit hook fails.

Fix an incorrect architecture macro check that prevented CPU prefetching in the free-threaded garbage collector on 32-bit Windows builds.

Use compiler option -Og in case of clang-cl debug builds on Windows to reduce stack usage. Patch by Chris Eibl.

Reading from the console on Windows now continues if the read was cancelled by Ctrl+C, but the :const:`~signal.SIGINT` handler did not raise an exception. Previously the read ended as if at end of file.

Fix the encoding of the standard streams in the legacy Windows stdio mode (:envvar:`PYTHONLEGACYWINDOWSSTDIO`). It is now the code page of the console, as in Python 3.7, not the ANSI code page.

:func:`os.device_encoding` on Windows now returns the code page of any console file descriptor, not only 0, 1 and 2, and returns None for other character devices like NUL. The UTF-8 code page is now reported as "utf-8" instead of "cp65001".

Propagate errors that occur while converting macOS system proxy settings.

Fix the completion list and the call tip grabbing the focus on macOS with Tcl/Tk 9.1.

Make IDLE keyboard shortcuts with ascii letters work when Caps Lock is on even when only one of the upper and lowercase versions are defined.

IDLE no longer applies syntax coloring to the text entered for :func:`input` in the Shell.

Fix IDLE failing to find the opening parenthesis when a continuation line inside the parentheses starts with else of a conditional expression or with yield.

Fix saving a truncated number when an integer entry in the IDLE Settings dialog is blanked with the Backspace key.

Ctrl-C in the IDLE Shell now interrupts blocking calls such as :func:`time.sleep` and :meth:`socket.recv <socket.socket.recv>`.

Colorize the soft keyword type in IDLE.

IDLE no longer hangs when opening a file with very long lines. Only the first 2,000 characters of a line are colorized.

IDLE no longer fails to start with python -m idlelib, and its user process no longer fails to start, when the current directory contains user files with the same names as standard library modules that IDLE imports, such as random.py or tkinter.py.

Fix parsing of command line arguments in the IDLE "Run... Customized" dialog on Windows: backslashes are no longer treated as escape characters. Fix also display of the previous arguments in the dialog.

The IDLE search dialogs now show a regular expression error below the entry instead of in a message box.

Fix calltips, parenthesis matching and auto-indent in the IDLE Shell after output containing unbalanced quotes or parentheses.

In IDLE, Tab in a string that is not the start of a file name inserts a tab instead of opening the completion list.

Fix running IDLE with the -s option together with -c, -r or -: the command or script now runs after the startup file, without an error dialog and without restarting the shell.

IDLE now reports any exception raised by compiling the source, such as :exc:`MemoryError` for too deeply nested source, instead of hanging the Shell.

Remove the border around the IDLE Shell sidebar, which was drawn in the window background color and stood out with dark themes.

Fix a hang of the IDLE Shell when code run under the debugger raises :exc:`KeyboardInterrupt`.

Consolidate IDLE's mouse wheel handling in idlelib.util. wheel_event moves there from idlelib.tree and joins x11_buttons, which tells whether Tk reports wheel rotations to a widget as <Button-4>/<Button-5> events, and bind_wheel, which binds whichever events Tk sends.

Stop deleting tkinter submodules when idlelib.run is imported.

Fix IDLE failing to start when opening a file which does not exist yet. Fix a traceback when a file open in the IDLE editor is deleted by another program; IDLE now asks whether to close the window, save the file elsewhere, or ignore it.

IDLE no longer fails to start when a user configuration file is corrupt. The unparsable file is renamed with a ".bad" suffix, default settings are used instead, and a warning lists the affected files.

Prevent IDLE from failing to start when a font reports a zero width for the '0' character. Such a broken font caused a :exc:`ZeroDivisionError`; the editor now falls back to the configured width.

Fix display of :exc:`NameError` and :exc:`AttributeError` with multi-line message.

python-gdb.py is now able to format an invalid Unicode string: render invalid characters as \Uhhhhhhhh instead of raising an exception. Patch by Victor Stinner.

Fix Argument Clinic generating code which reads an optional positional argument which was not passed, if the function has a **kwds parameter.

Fix Argument Clinic for @getter and @setter in a preprocessor conditional block. It failed with an internal error. Argument Clinic now also rejects the accessors of the same attribute with different C basenames, and the same accessor defined twice, which silently generated invalid or duplicated entries of :c:type:`PyGetSetDef`.

Fix Argument Clinic generating the flags of the optional groups in different order on 32-bit and 64-bit platforms.

Argument Clinic now supports the --dry-run and --diff options. They list the files which would be changed, or write a unified diff of the changes to the standard output, without modifying any file.

Fix Argument Clinic support of parameters with a default value used together with optional groups. Such parameters were always required in the generated parsing code.

Fix a crash in :c:func:`_PyTuple_Resize` when resizing a non-empty tuple to a negative or too large size. It now raises :exc:`SystemError` or :exc:`MemoryError` respectively.

:c:func:`PyInitConfig_SetStr` now releases a previously configured value and preserves it if conversion of the replacement fails.

Fix a reference leak when :c:func:`_PyTuple_Resize` fails.

Fix the :c:macro:`PySlot_END` macro for C++: initialize all members to avoid compiler warnings. Patch by Victor Stinner.

Fix :c:macro:`Py_ARRAY_LENGTH()` macro on C++: do not use __builtin_types_compatible_p() on C++. Patch by Victor Stinner.

Fix :c:func:`!_PyUnicodeWriter_WriteLatin1String` when the writer buffer kind is UCS-2 or UCS-4. Patch by Victor Stinner.

Fix :c:macro:`Py_CLEAR` and :c:macro:`Py_SETREF` macros on C++: implement them using auto instead of decltype(). Using decltype() produced invalid code when clearing/setting an array item. Patch by Victor Stinner.

Add tests on the undocumented and deprecated _Py_Identifier C API. Patch by Victor Stinner.

:c:func:`PyImport_CreateModuleFromInitfunc` now sets the package context while calling initfunc, so that a single-phase init submodule created with only the last component of its name gets the full name from the spec.

Fix :c:func:`PyBytesWriter_Resize` to handle properly memory allocation failure. Leave the writer unchanged on error, instead of leaving it in an inconsistent state. Patch by Victor Stinner.

Don't set the result in error in :c:func:`PyLong_AsInt32`, :c:func:`PyLong_AsUInt32`, :c:func:`PyLong_AsInt64` and :c:func:`PyLong_AsUInt64`. Leave the result unchanged in this case. Patch by Victor Stinner.