Remove two invalid "peephole" optimizations from the bytecode compiler.
Do not create frame objects when creating :class:`super` object. Patch by Kumar Aditya.
Added more fined-grained specialization failure stats regarding the
COMPARE_OP
bytecode.
The delegation of :func:`int` to :meth:`__trunc__` is now deprecated.
Calling int(a)
when type(a)
implements :meth:`__trunc__` but not
:meth:`__int__` or :meth:`__index__` now raises a :exc:`DeprecationWarning`.
Reorder code emitted by the compiler for a :keyword:`try`-:keyword:`except` block so that the :keyword:`else` block's code immediately follows the :keyword:`try` body (without a jump). This is more optimal for the happy path.
Allow passing iterable
as a keyword argument to :func:`enumerate` again.
Patch by Jelle Zijlstra.
Replace several stack manipulation instructions (DUP_TOP
,
DUP_TOP_TWO
, ROT_TWO
, ROT_THREE
, ROT_FOUR
, and ROT_N
)
with new :opcode:`COPY` and :opcode:`SWAP` instructions.
Use two or three bytecodes to implement most calls.
Calls without named arguments are implemented as a sequence of two
instructions: PRECALL; CALL
. Calls with named arguments are implemented
as a sequence of three instructions: PRECALL; KW_NAMES; CALL
. There are
two different PRECALL
instructions: PRECALL_FUNTION
and
PRECALL_METHOD
. The latter pairs with LOAD_METHOD
.
This partition into pre-call and call allows better specialization, and thus better performance ultimately.
There is no change in semantics.
Fix an assert when parsing some invalid N escape sequences in f-strings.
Improve error message on invalid calls to :meth:`BaseExceptionGroup.__new__`.
Fix memory leak in code objects generated by deepfreeze. Patch by Kumar Aditya.
Speed up calls to :meth:`weakref.ref.__call__` by using the PEP 590
vectorcall
calling convention. Patch by Donghee Na.
Fix a race condition on setting a type __bases__
attribute: the internal
function add_subclass()
now gets the PyTypeObject.tp_subclasses
member after calling :c:func:`PyWeakref_NewRef` which can trigger a garbage
collection which can indirectly modify PyTypeObject.tp_subclasses
. Patch
by Victor Stinner.
python -X showrefcount
now shows the total reference count after
clearing and destroyed the main Python interpreter. Previously, it was shown
before. Patch by Victor Stinner.
Add ASYNC_GEN_WRAP opcode to wrap the value to be yielded in async
generators. Removes the need to special case async generators in the
YIELD_VALUE
instruction.
Optimize some modulo operations in Objects/longobject.c
. Patch by
Jeremiah Vivian.
Add new RETURN_GENERATOR
bytecode to make generators. Simplifies calling
Python functions in the VM, as they no longer any need to special case
generator functions.
Also add JUMP_NO_INTERRUPT
bytecode that acts like JUMP_ABSOLUTE
,
but does not check for interrupts.
The integer division //
implementation has been optimized to better let
the compiler understand its constraints. It can be 20% faster on the amd64
platform when dividing an int by a value smaller than 2**30
.
Fix invalid signature of _zoneinfo
's module_free
function to resolve
a crash on wasm32-emscripten platform.
Ensure that "small" integers created by :meth:`int.from_bytes` and :class:`decimal.Decimal` are properly cached.
Fix the class building error when the arguments are constants and CALL_FUNCTION_EX is used.
Fixes calculation of :data:`sys._base_executable` when inside a virtual environment that uses symlinks with different binary names than the base environment provides.
Correctly calculate indentation levels for lines with whitespace character that are ended by line continuation characters. Patch by Pablo Galindo
Add CAN Socket support for NetBSD.
Do not use POSIX semaphores on NetBSD
Improve the :exc:`TypeError` message for non-string second arguments passed to the built-in functions :func:`getattr` and :func:`hasattr`. Patch by Géry Ogam.
Restore support for non-integer arguments of :func:`random.randrange` and :func:`random.randint`.
Make the IDLE doc URL on the About IDLE dialog clickable.
Remove loop variables that are leaking into modules' namespaces.
In :func:`typing.get_type_hints`, support evaluating bare stringified
ClassVar
annotations. Patch by Gregory Beauregard.
Don't leak x
& uspace
intermediate vars in
:class:`textwrap.TextWrapper`.
Add the get_write_buffer_limits
method to
:class:`asyncio.transports.WriteTransport` and to the SSL transport.
Note the configparser deprecations will be removed in Python 3.12.
The deprecated :mod:`unittest` APIs removed in 3.11a1 have been temporarily restored to be removed in 3.12 while cleanups in external projects go in.
In :func:`typing.get_type_hints`, support evaluating stringified
ClassVar
and Final
annotations inside Annotated
. Patch by
Gregory Beauregard.
Add missing test for :class:`types.TracebackType` and :class:`types.FrameType`. Calculate them directly from the caught exception without calling :func:`sys.exc_info`.
Allow :data:`typing.Annotated` to wrap :data:`typing.Final` and :data:`typing.ClassVar`. Patch by Gregory Beauregard.
Remove :meth:`~object.__class_getitem__` from :class:`pathlib.PurePath` as this class was not supposed to be generic.
Fix command-line option -d
/--directory
in module :mod:`http.server`
which is ignored when combined with command-line option --cgi
. Patch by
Géry Ogam.
Make :meth:`mock.patch` raise a :exc:`TypeError` with a relevant error message on invalid arg. Previously it allowed a cryptic :exc:`AttributeError` to escape.
In importlib.metadata.EntryPoint.pattern
, avoid potential REDoS by
limiting ambiguity in consecutive whitespace.
Removed private method from importlib.metadata.Path
. Sync with
importlib_metadata 4.10.0.
Remove unused branch from typing._remove_dups_flatten
:mod:`asyncio` generic classes now return :class:`types.GenericAlias` in
__class_getitem__
instead of the same class.
Support passing filter instances in the filters
values of handlers
and loggers
in the dictionary passed to
:func:`logging.config.dictConfig`.
Use dis.Positions
in dis.Instruction
instead of a regular tuple
.
:mod:`pdb` now gracefully handles help
when :attr:`~module.__doc__` is
missing, for example when run with pregenerated optimized .pyc
files.
Python uses the same time Epoch on all platforms. Add an explicit unit test to ensure that it's the case. Patch by Victor Stinner.
Add :func:`typing.reveal_type`. Patch by Jelle Zijlstra.
:mod:`subprocess` now imports Windows-specific imports when msvcrt
module is available, and POSIX-specific imports on all other platforms. This
gives a clean exception when _posixsubprocess
is not available (e.g.
Emscripten browser target).
IntEnum
, IntFlag
, and StrEnum
use the mixed-in type for their
str()
and format()
output.
Optimize :meth:`pathlib.Path.iterdir` by removing an unnecessary check for special entries.
Document :meth:`pathlib.Path.absolute` (which has always existed).
The pathlib module's obsolete and internal _Accessor
class has been
removed to prepare the terrain for upcoming enhancements to the module.
Speed up :func:`math.isqrt` for small positive integers by replacing two division steps with a lookup table.
Improve error message when creating a new :class:`enum.Enum` type
subclassing an existing Enum
with _member_names_
using
:meth:`enum.Enum.__call__`.
Fix a bug in :func:`inspect.signature` that was causing it to fail on some
subclasses of classes with a __text_signature__
referencing module
globals. Patch by Weipeng Hong.
Fixed case where failing :func:`asyncio.ensure_future` did not close the coroutine. Patch by Kumar Aditya.
Fix an issue with :meth:`tarfile.TarFile.getmember` getting a directory name with a trailing slash.
Update :mod:`zoneinfo` to rely on importlib.resources traversable API.
Now :func:`inspect.getmembers` only gets :attr:`__bases__` attribute from class type. Patch by Weipeng Hong.
Fix exception in argparse help text generation if a
:class:`argparse.BooleanOptionalAction` argument's default is
argparse.SUPPRESS
and it has help
specified. Patch by Felix
Fontein.
Fix substitution of :class:`~typing.ParamSpec` in
:data:`~typing.Concatenate` with different parameter expressions.
Substitution with a list of types returns now a tuple of types. Substitution
with Concatenate
returns now a Concatenate
with concatenated lists
of arguments.
Fixes :file:`escape4chm.py` script used when building the CHM documentation file
Mocks can no longer be provided as the specs for other Mocks. As a result,
an already-mocked object cannot be passed to mock.Mock()
. This can uncover
bugs in tests since these Mock-derived Mocks will always pass certain tests
(e.g. isinstance) and builtin assert functions (e.g.
assert_called_once_with) will unconditionally pass.
Ensures test_importlib.test_windows
cleans up registry keys after
completion.
test_ftplib now silently ignores socket errors to prevent logging unhandled threading exceptions. Patch by Victor Stinner.
Fix test_gdb.test_pycfunction() for Python built with clang -Og
.
Tolerate inlined functions in the gdb traceback. Patch by Victor Stinner.
Fix a Python crash in test_lib2to3 when using Python built in debug mode: limit the recursion limit. Patch by Victor Stinner.
test_peg_generator now disables compiler optimization when testing compilation of its own C extensions to significantly speed up the testing on non-debug builds of CPython.
Fix test_json
tests checking for :exc:`RecursionError`: modify these
tests to use support.infinite_recursion()
. Patch by Victor Stinner.
Skip test_builtin PTY tests on non-ASCII characters if the readline module is loaded. The readline module changes input() behavior, but test_builtin is not intended to test the readline module. Patch by Victor Stinner.
Add :func:`test.support.requires_fork` decorators to mark tests that require a working :func:`os.fork`.
Add :func:`test.support.requires_subprocess` decorator to mark tests which
require working :mod:`subprocess` module or os.spawn*
. The
wasm32-emscripten platform has no support for processes.
Disable 'descriptions' when running tests internally.
Tidied up configure.ac so that conftest.c is truncated rather than appended. This assists in the case where the 'rm' of conftest.c fails to happen between tests. Downstream issues such as a clobbered SOABI can result.
Fix the test checking if the C compiler supports -Og
option in the
./configure
script to also use -Og
on clang which supports it. Patch
by Victor Stinner.
Fix GCC detection in setup.py when cross-compiling. The C compiler is now run with LC_ALL=C. Previously, the detection failed with a German locale.
:program:`configure` no longer uses AC_C_CHAR_UNSIGNED
macro and
pyconfig.h
no longer defines reserved symbol __CHAR_UNSIGNED__
.
Use global singletons for single byte bytes objects in deepfreeze.
Deepfreeze now uses cached small integers as it saves some space for common small integers.
Merge all deep-frozen files into one for space savings. Patch by Kumar Aditya.
The build now defaults to using 30-bit digits for Python integers.
Previously either 15-bit or 30-bit digits would be selected, depending on
the platform. 15-bit digits may still be selected using the
--enable-big-digits=15
option to the configure
script, or by
defining PYLONG_BITS_IN_DIGIT
in pyconfig.h
.
Update Windows installer to use SQLite 3.37.2.
Detect musl libc as a separate SOABI (tagged as linux-musl
).
The traditional EXE/MSI based installer for Windows is now available for ARM64
os.path.abspath("C:CON") is now fixed to return "\.CON", not the same path. The regression was true of all legacy DOS devices such as COM1, LPT1, or NUL.
The installer now offers a command-line only option to add the installation directory to the end of :envvar:`PATH` instead of at the start.
Update macOS installer to SQLite 3.37.2.
Clarify close, quit, and exit in IDLE. In the File menu, 'Close' and 'Exit' are now 'Close Window' (the current one) and 'Exit' is now 'Exit IDLE' (by closing all windows). In Shell, 'quit()' and 'exit()' mean 'close Shell'. If there are no other windows, this also exits IDLE.
Remove the PyHeapType_GET_MEMBERS()
macro. It was exposed in the public
C API by mistake, it must only be used by Python internally. Use the
PyTypeObject.tp_members
member instead. Patch by Victor Stinner.
Move _Py_GetAllocatedBlocks() and _PyObject_DebugMallocStats() private functions to the internal C API. Patch by Victor Stinner.
The internal function _PyType_GetModuleByDef now correctly handles inheritance patterns involving static types.
:c:type:`Py_buffer` and various Py_buffer
related functions are now part
of the limited API and stable ABI.
Fixed bug in the tokenizer that prevented PyRun_InteractiveOne
from
parsing from the provided FD.