Skip to content

Latest commit

 

History

History
1671 lines (1192 loc) · 37.7 KB

3.13.0b1.rst

File metadata and controls

1671 lines (1192 loc) · 37.7 KB

Update bundled libexpat to 2.6.2

Detect BLAKE2, SHA3, Shake, & truncated SHA512 support in the OpenSSL-ish libcrypto library at build time. This allows :mod:`hashlib` to be used with libraries that do not to support every algorithm that upstream OpenSSL does.

Add instrumented opcodes to YIELD_VALUE assertion for tracing cases.

When a builtin or extension module is imported for the first time, while a subinterpreter is active, the module's init function is now run by the main interpreter first before import continues in the subinterpreter. Consequently, single-phase init modules now fail in an isolated subinterpreter without the init function running under that interpreter, whereas before it would run under the subinterpreter before failing, potentially leaving behind global state and callbacks and otherwise leaving the module in an inconsistent state.

Don't use designated initializer syntax in inline functions in internal headers. They cause problems for C++ or MSVC users who aren't yet using the latest C++ standard (C++20). While internal, pycore_backoff.h, is included (indirectly, via pycore_code.h) by some key 3rd party software that does so for speed.

Improve performance of :func:`json.dumps` and :func:`json.dump` when using the argument indent. Depending on the data the encoding using :func:`json.dumps` with indent can be up to 2 to 3 times faster.

In --disable-gil builds, the GIL will be enabled while loading C extension modules. If the module indicates that it supports running without the GIL, the GIL will be disabled once loading is complete. Otherwise, the GIL will remain enabled for the remainder of the interpreter's lifetime. This behavior does not apply if the GIL has been explicitly enabled or disabled with PYTHON_GIL or -Xgil.

Fix incorrect :exc:`UnboundLocalError` when two comprehensions in the same function both reference the same name, and in one comprehension the name is bound while in the other it's an implicit global.

Allow the Linux perf support to work without frame pointers using perf's advanced JIT support. The feature is activated when using the PYTHON_PERF_JIT_SUPPORT environment variable or when running Python with -Xperf_jit. Patch by Pablo Galindo.

Add sys._is_gil_enabled() function that returns whether the GIL is currently enabled. In the default build it always returns True because the GIL is always enabled. In the free-threaded build, it may return True or False.

Break a loop between the Python implementation of the :mod:`decimal` module and the Python code for integer to string conversion. Also optimize integer to string conversion for values in the range from 9_000 to 135_000 decimal digits.

Fix :func:`sys.set_asyncgen_hooks` not to be partially set when raising :exc:`TypeError`.

Compiler populates the new __firstlineno__ field on a class with the line number of the first line of the class definition.

Fix an issue where the type cache can expose a previously accessed attribute when a finalizer is run.

update async_generator.athrow().close() and async_generator.asend().close() to close their section of the underlying async generator

The :term:`interactive` interpreter is now implemented in Python, which allows for a number of new features like colors, multiline input, history viewing, and paste mode. Contributed by Pablo Galindo, Łukasz Langa and Lysandros Nikolaou based on code from the PyPy project.

Implement PEP 667: converted :attr:`FrameType.f_locals <frame.f_locals>` and :c:func:`PyFrame_GetLocals` to return a write-through proxy object when the frame refers to a function or comprehension.

Fix crash in compiler on 'async with' that has many context managers.

Change how to use the tier 2 interpreter. Instead of running Python with -X uops or setting the environment variable PYTHON_UOPS=1, this choice is now made at build time by configuring with --enable-experimental-jit=interpreter.

Beware! This changes the environment variable to enable or disable micro-ops to PYTHON_JIT. The old PYTHON_UOPS is no longer used.

Update JIT compilation to use LLVM 18

:ref:`Annotation scopes <annotation-scopes>` within classes can now contain comprehensions. However, such comprehensions are not inlined into their parent scope at runtime. Patch by Jelle Zijlstra.

Fix bug where generator.close does not free the generator frame's locals.

Don't consider :mod:`__future__` imports with dots before the module name.

Make sure that the Executor objects in the COLD_EXITS array aren't assumed to be GC-able (which would access bytes outside the object).

Lazy load frame line number to improve performance of tracing

Improve :exc:`SyntaxError` message for imports without names, like in from x import and import cases. It now points out to users that :keyword:`import` expects at least one name after it.

Improve :exc:`SyntaxError` message for empty type param brackets.

Added a get_jit_code() method to access JIT compiled machine code from the UOp Executor when the experimental JIT is enabled. Patch by Anthony Shaw.

Add option for compiler's codegen to save nested instruction sequences for introspection.

Redirect stdout and stderr to system log when embedded in an Android app.

:ref:`annotation scope <annotation-scopes>` within class scopes can now contain lambdas.

Prevent agen.aclose() objects being re-used after .throw().

prevent concurrent access to an async generator via athrow().throw() or asend().throw()

Fixed a possible segfault during garbage collection of _asyncio.FutureIter objects

Fix a :exc:`RuntimeWarning` when calling agen.aclose().throw(Exception).

Fix mimalloc allocator for huge memory allocation (around 8,589,934,592 GiB) on s390x. Patch by Victor Stinner.

Fix issue where an object's dict would get out of sync with the object's internal values when being cleared. obj.__dict__.clear() now clears the internal values, but leaves the dict attached to the object.

Improve the performance of the following :class:`bytes` and :class:`bytearray` methods by adapting them to the :c:macro:`METH_FASTCALL` calling convention:

Speed up calls to :func:`str` with positional-only argument, by using the PEP 590 vectorcall calling convention. Patch by Erlend Aasland.

Give _PyInstructionSequence a Python interface and use it in tests.

Statically allocated objects are, by definition, immortal so must be marked as such regardless of whether they are in extension modules or not.

Remove unhandled PY_MONITORING_EVENT_BRANCH and PY_MONITORING_EVENT_EXCEPTION_HANDLED events from :func:`sys.settrace`.

Extension modules may indicate to the runtime that they can run without the GIL. Multi-phase init modules do so by calling providing Py_MOD_GIL_NOT_USED for the Py_mod_gil slot, while single-phase init modules call PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED) from their init function.

Implement PEP 696, adding support for defaults on type parameters. Patch by Jelle Zijlstra.

Add two new functions to the C-API, :c:func:`PyRefTracer_SetTracer` and :c:func:`PyRefTracer_GetTracer`, that allows to track object creation and destruction the same way the :mod:`tracemalloc` module does. Patch by Pablo Galindo

Improved the performance of :func:`sys.settrace` significantly

Improve the error message when a script shadowing a module from the standard library causes :exc:`AttributeError` to be raised. Similarly, improve the error message when a script shadowing a third party module attempts to access an attribute from that third party module while still initialising.

Elide uninformative traceback indicators in return and simple assignment statements. Patch by Pablo Galindo.

Allow the globals and locals arguments to :func:`exec` and :func:`eval` to be passed as keywords.

A :exc:`DeprecationWarning` is now emitted if you fail to pass a value to the new type_params parameter of typing._eval_type() or typing.ForwardRef._evaluate(). (Using either of these private and undocumented functions is discouraged to begin with, but failing to pass a value to the type_params parameter may lead to incorrect behaviour on Python 3.12 or newer.)

Add an optional second type parameter to :class:`typing.ContextManager` and :class:`typing.AsyncContextManager`, representing the return types of :meth:`~object.__exit__` and :meth:`~object.__aexit__` respectively. This parameter defaults to bool | None.

The enum module allows method named _repr_* to be defined on Enum types.

Add type parameter defaults to :class:`typing.Generator` and :class:`typing.AsyncGenerator`.

Mime type text/x-rst is now supported by :mod:`mimetypes`.

The Python implementation of the decimal module could appear to hang in relatively small power cases (like 2**117) if context precision was set to a very high value. A different method to check for exactly representable results is used now that doesn't rely on computing 10**precision (which could be effectively too large to compute).

breakpoint() and pdb.set_trace() now enter the debugger immediately after the call rather than before the next line is executed.

Add :mod:`pdb` support for zipapps

Add signature for :class:`sqlite3.Connection` objects.

Use a Y2038 compatible openssl time function when available.

Fix :func:`inspect.signature` for non-comparable callables.

Fix :func:`inspect.signature` for the result of the :func:`functools.cmp_to_key` call.

On Android, :any:`sysconfig.get_platform` now returns the format specified by PEP 738.

Allow to specify the signature of custom callable instances of extension type by the __text_signature__ attribute. Specify signatures of :class:`operator.attrgetter`, :class:`operator.itemgetter`, and :class:`operator.methodcaller` instances.

Fix an edge case in :func:`binascii.a2b_base64` strict mode, where excessive padding is not detected when no padding is necessary.

Add the :class:`!PhotoImage` methods :meth:`!read` to read an image from a file and :meth:`!data` to get the image data. Add background and grayscale parameters to :class:`!PhotoImage` method :meth:`!write`.

Add the :class:`!PhotoImage` method :meth:`!copy_replace` to copy a region from one image to other image, possibly with pixel zooming and/or subsampling. Add from_coords parameter to :class:`!PhotoImage` methods :meth:`!copy()`, :meth:`!zoom()` and :meth:`!subsample()`. Add zoom and subsample parameters to :class:`!PhotoImage` method :meth:`!copy()`.

Fix a bug where :meth:`sqlite3.Connection.iterdump` could fail if a custom :attr:`row factory <sqlite3.Connection.row_factory>` was used. Patch by Erlend Aasland.

Fix regression introduced in gh-103193 that meant that calling :func:`inspect.getattr_static` on an instance would cause a strong reference to that instance's class to persist in an internal cache in the :mod:`inspect` module. This caused unexpected memory consumption if the class was dynamically created, the class held strong references to other objects which took up a significant amount of memory, and the cache contained the sole strong reference to the class. The fix for the regression leads to a slowdown in :func:`!getattr_static`, but the function should still be significantly faster than it was in Python 3.11. Patch by Alex Waygood.

Speed up :func:`itertools.pairwise` in the common case by up to 1.8x.

Improve the behavior of user-defined subclasses of :class:`ast.AST`. Such classes will now require no changes in the usual case to conform with the behavior changes of the :mod:`ast` module in Python 3.13. Patch by Jelle Zijlstra.

Fixed :func:`unittest.mock.create_autospec` to configure parent mock with keyword arguments.

Fix incorrect argument substitution when :data:`typing.Unpack` is used with the builtin :class:`tuple`. :data:`!typing.Unpack` now raises :exc:`TypeError` when used with certain invalid types. Patch by Jelle Zijlstra.

Add command-line interface for the :mod:`random` module. Patch by Hugo van Kemenade.

Fix :mod:`zipimport` reading of ZIP64 files with file entries that are too big or offset too far.

Fix :func:`os.path.normpath` for UNC paths on Windows. Speed up :func:`os.path.splitroot` with a native implementation.

Change the unknown filename of :mod:`warnings` from sys to <sys> to clarify that it's not a real filename.

Fix erroneous :exc:`NameError` when calling :func:`typing.get_type_hints` on a class that made use of PEP 695 type parameters in a module that had from __future__ import annotations at the top of the file. Patch by Alex Waygood.

Add parameter fileobj check for :func:`tarfile.TarFile.addfile`

Don't raise :exc:`DeprecationWarning` when a :term:`sequence` of parameters is used to bind indexed, nameless placeholders. See also :gh:`100668`.

Fix TypeError in :func:`email.message.Message.get_payload` when the charset is RFC 2231 encoded.

Fix IndexError when parse some emails with invalid Message-ID (including one-off addresses generated by Microsoft Outlook).

Improve the error messages emitted by :mod:`tarfile` deprecation warnings relating to PEP 706. If a filter argument is not provided to extract() or extractall, the deprecation warning now points to the line in the user's code where the relevant function was called. Patch by Alex Waygood.

Speed up :meth:`pathlib.Path.glob` by omitting an initial :meth:`~pathlib.Path.is_dir` call. As a result of this change, :meth:`~pathlib.Path.glob` can no longer raise :exc:`OSError`.

:mod:`site` module now parses .pth file with UTF-8 first, and :term:`locale encoding` if UnicodeDecodeError happened. It supported only locale encoding before.

We've exposed the low-level :mod:`!_interpreters` module for the sake of the PyPI implementation of PEP 734. It was sometimes available as the :mod:`!_xxsubinterpreters` module and was formerly used only for testing. For the most part, it should be considered an internal module, like :mod:`!_thread` and :mod:`!_imp`. See https://discuss.python.org/t/pep-734-multiple-interpreters-in-the-stdlib/41147/26.

Speed up :meth:`pathlib.Path.glob` by not scanning directories for non-wildcard pattern segments.

Speed up :meth:`pathlib.Path.iterdir` by using :func:`os.scandir` internally.

Speed up :meth:`pathlib.Path.walk` by working with strings internally.

Change the new multi-separator support in :meth:`asyncio.StreamReader.readuntil` to only accept tuples of separators rather than arbitrary iterables.

Fixes a bug when :class:`doctest.DocTestFinder` was failing on wrapped builtin_function_or_method.

Largely restored import time performance of configparser by avoiding dataclasses.

Speedup :func:`os.path.commonpath` on Unix.

Fix _simple_enum to detect aliases when multiple arguments are present but only one is the member value.

Speedup :func:`os.path.join`.

Support package.module as filename for break command of :mod:`pdb`

the status codes enum with constants in http.HTTPStatus are updated to include the names from RFC9110. This RFC includes some HTTP statuses previously only used for WEBDAV and assigns more generic names to them.

The old constants are preserved for backwards compatibility.

Speedup :func:`os.path.relpath`.

Speed up :meth:`pathlib.Path.glob` by working with strings internally.

Add colour to doctest output. Patch by Hugo van Kemenade.

:meth:`ipaddress.IPv6Address.is_loopback` will now return True for IPv4-mapped loopback addresses, i.e. addresses in the ::ffff:127.0.0.0/104 address space.

Fix issue where :func:`os.path.realpath` stopped resolving symlinks after encountering a symlink loop on POSIX.

Improved behavior of :class:`asyncio.TaskGroup` when an external cancellation collides with an internal cancellation. For example, when two task groups are nested and both experience an exception in a child task simultaneously, it was possible that the outer task group would misbehave, because its internal cancellation was swallowed by the inner task group.

In the case where a task group is cancelled externally and also must raise an :exc:`ExceptionGroup`, it will now call the parent task's :meth:`~asyncio.Task.cancel` method. This ensures that a :exc:`asyncio.CancelledError` will be raised at the next :keyword:`await`, so the cancellation is not lost.

An added benefit of these changes is that task groups now preserve the cancellation count (:meth:`asyncio.Task.cancelling`).

In order to handle some corner cases, :meth:`asyncio.Task.uncancel` may now reset the undocumented _must_cancel flag when the cancellation count reaches zero.

Add :data:`typing.TypeIs`, implementing PEP 742. Patch by Jelle Zijlstra.

Fix support of non-ASCII user names in bytes paths in :func:`os.path.expanduser` on Posix.

:func:`os.path.ismount` is now 2-3 times faster if the user has permissions.

Only treat '\n', '\r' and '\r\n' as line separators in re-folding the :mod:`email` messages. Preserve control characters '\v', '\f', '\x1c', '\x1d' and '\x1e' and Unicode line separators '\x85', '\u2028' and '\u2029' as is.

Convert :mod:`!_ctypes` to multi-phase initialisation (PEP 489).

Add the :func:`mimetypes.guess_file_type` function which works with file path. Passing file path instead of URL in :func:`~mimetypes.guess_type` is :term:`soft deprecated`.

webbrowser CLI: replace getopt with argparse, add long options. Patch by Hugo van Kemenade.

Name suggestions for :exc:`AttributeError` and :exc:`ImportError` now only include underscored names if the original name was underscored.

Don't show empty fields (value None or []) in :func:`ast.dump` by default. Add show_empty=False parameter to optionally show them.

Added :attr:`!name` and :attr:`!mode` attributes for compressed and archived file-like objects in modules :mod:`bz2`, :mod:`lzma`, :mod:`tarfile` and :mod:`zipfile`. The value of the :attr:`!mode` attribute of :class:`gzip.GzipFile` was changed from integer (1 or 2) to string ('rb' or 'wb'). The value of the :attr:`!mode` attribute of the readable file-like object returned by :meth:`zipfile.ZipFile.open` was changed from 'r' to 'rb'.

Fix :func:`inspect.signature()` to correctly handle parameter defaults on methods in extension modules that use names defined in the module namespace.

Honor :mod:`atexit` for all :mod:`multiprocessing` start methods

Print colorized exception just like built-in traceback in :mod:`pdb`

Speed up pickling of :class:`pathlib.PurePath` objects. Patch by Barney Gale.

Support opcode events in :mod:`bdb`

:mod:`!ncurses`: fixed a crash that could occur on macOS 13 or earlier when Python was built with Apple Xcode 15's SDK.

Enabled arbitrary statements and evaluations in :mod:`pdb` shell to access the local variables of the current frame, which made it possible for multi-scope code like generators or nested function to work.

Add :meth:`~object.__class_getitem__` to :class:`types.GeneratorType` and :class:`types.CoroutineType` for type hinting purposes. Patch by James Hilton-Balfe.

The :class:`types.SimpleNamespace` now accepts an optional positional argument which specifies initial values of attributes as a dict or an iterable of key-value pairs.

Fix assertion errors caused by whitespace in metavars or SUPPRESS-ed groups in :mod:`argparse` by simplifying usage formatting. Patch by Ali Hamdan.

Adjust logging.LogRecord to use time.time_ns() and fix minor bug related to floating point math.

Bring pure Python implementation functools.partial.__new__ more in line with the C-implementation by not just always checking for the presence of the attribute 'func' on the first argument of partial. Instead, both the Python version and the C version perform an isinstance(func, partial) check on the first argument of partial.

HEAD requests are no longer upgraded to GET request during redirects in urllib.

Setting the :mod:`!tkinter` module global :data:`!wantobjects` to 2 before creating the :class:`~tkinter.Tk` object or call the :meth:`!wantobjects` method of the :class:`!Tk` object with argument 2 makes now arguments to callbacks registered in the :mod:`tkinter` module to be passed as various Python objects (int, float, bytes, tuple), depending on their internal representation in Tcl, instead of always str. :data:`!tkinter.wantobjects` is now set to 2 by default.

Fix several IndexError when parse emails with truncated Message-ID, address, routes, etc, e.g. example@.

Add mime type mapping for .md <-> text/markdown

:func:`shutil.chown` now supports dir_fd and follow_symlinks keyword arguments.

Fix parsing of emails with invalid address headers having a leading or trailing dot. Patch by tsufeki.

Add the :meth:`!after_info` method for Tkinter widgets.

The minimum Sphinx version required for the documentation is now 6.2.1.

Fixes Windows build when invoked directly (not through the :file:`build.bat` script) without specifying a value for UseTIER2.

The :file:`configure` option :option:`--with-system-libmpdec` now defaults to yes. The bundled copy of libmpdecimal will be removed in Python 3.15.

Fix building against recent libedit versions by detecting readline hook signatures in :program:`configure`.

A testbed project was added to run the test suite on Android.

Increase WASI stack size from 512 KiB to 8 MiB and the initial memory from 10 MiB to 20 MiB. Patch by Victor Stinner.

:program:`configure` now uses :program:`pkg-config` to detect :mod:`decimal` dependencies if the :option:`--with-system-libmpdec` option is given.

Update Windows installer to use libmpdecimal 4.0.0.

:func:`os.mkdir` now accepts mode of 0o700 to restrict the new directory to the current user.

Fixes launcher updates not being installed.

The multiprocessing module now passes the STARTF_FORCEOFFFEEDBACK flag when spawning processes to tell Windows not to change the mouse cursor.

Update Windows installer to use SQLite 3.45.3.

Suppress the warning displayed on virtual environment creation when the requested and created paths differ only by a short (8.3 style) name. Warnings will continue to be shown if a junction or symlink in the path caused the venv to be created in a different location than originally requested.

Fixes virtual environments not correctly launching when created from a Store install.

Update macOS installer to use libmpdecimal 4.0.0.

iOS preprocessor symbol usage was made compatible with older macOS SDKs.

Update macOS installer to use SQLite 3.45.3.

Use :file:`~/.config/fish/conf.d` configs and :program:`fish_add_path` to set :envvar:`PATH` when installing for the Fish shell.

Use user-selected color theme for Help => IDLE Doc.

Fix :c:macro:`Py_BUILD_ASSERT` and :c:macro:`Py_BUILD_ASSERT_EXPR` for non-constant expressions: use static_assert() on C11 and newer. Patch by Victor Stinner.

Add "Raw" variant of PyTime functions

Patch by Victor Stinner.

Restore functions removed in Python 3.13 alpha 1:

Patch by Victor Stinner.

Restore removed :c:func:`PyEval_InitThreads` function. Patch by Victor Stinner.

Improve validation logic in the C implementation of :meth:`datetime.datetime.fromisoformat` to better handle invalid years. Patch by Vlad Efanov.

Fixed skipitem()'s handling of the old 'w' and 'w#' formatters. These are no longer supported and now raise an exception if used.

Add a C-API for firing monitoring events.