Fix misleading default value in :func:`input`'s __text_signature__
.
Remove :opcode:`UNARY_POSITIVE`, :opcode:`ASYNC_GEN_WRAP` and :opcode:`LIST_TO_TUPLE`, replacing them with intrinsics.
Add new :opcode:`CALL_INSTRINSIC_1` instruction. Remove :opcode:`IMPORT_STAR`, :opcode:`PRINT_EXPR` and :opcode:`STOPITERATION_ERROR`, replacing them with the :opcode:`CALL_INSTRINSIC_1` instruction.
Remove the LOAD_ATTR_METHOD_WITH_DICT specialized instruction. Stats show it is not useful.
Added _PyFrame_NumSlotsForCodeObject
, which returns the number of slots
needed in a frame for a given code object.
Removed the co_nplaincellvars field from the code object, as it is redundant.
Fix :func:`int.__sizeof__` calculation to include the 1 element ob_digit array for 0 and False.
Update the native_thread_id field of PyThreadState after fork.
Fix an issue where "incomplete" frames could be briefly visible to C code while other frames are being torn down, possibly resulting in corruption or hard crashes of the interpreter while running finalizers.
Fix :exc:`SyntaxError` on comprehension rebind checking with names that are not actually redefined.
Now reassigning b
in [(b := 1) for a, b.prop in some_iter]
is
allowed. Reassigning a
is still disallowed as per PEP 572.
Add :meth:`int.is_integer` to improve duck type compatibility between :class:`int` and :class:`float`.
Improve the accuracy of sum()
with compensated summation.
Fix incorrect result and delay in :func:`socket.getfqdn`. Patch by Dominic Socular.
Convert vars
, dir
, next
, getattr
, and iter
to argument
clinic.
Improve the output of co_lines
by emitting only one entry for each line
range.
Handle NaNs when specializing :opcode:`COMPARE_OP` for :class:`float` values.
Redefine the _Py_CODEUNIT
typedef as a union to describe its layout to
the C compiler, avoiding type punning and improving clarity.
Internal compiler functions (in compile.c) now consistently return -1 on error and 0 on success.
The BINARY_SUBSCR_LIST_INT
and BINARY_SUBSCR_TUPLE_INT
instructions
are no longer used for negative integers because those instructions always
miss when encountering negative integers.
Initialize frame->previous in frameobject.c to fix a segmentation fault when accessing frames created by :c:func:`PyFrame_New`.
Improved the hashing algorithm for code objects, mitigating some hash collisions.
None
now hashes to a constant value. This is not a requirements change.
When built with --enable-pystats
, stats collection is now off by
default. To enable it early at startup, pass the -Xpystats
flag. Stats
are now always dumped, even if switched off.
Improve BUILD_LIST
opcode so that it works similarly to the
BUILD_TUPLE
opcode, by stealing references from the stack rather than
repeatedly using stack operations to set list elements. Implementation
details are in a new private API :c:func:`_PyList_FromArraySteal`.
Specialize FOR_ITER
for tuples.
Honor existing errors obtained when searching for mismatching parentheses in the tokenizer. Patch by Pablo Galindo
Improve the performance of :func:`hasattr` for type objects with a missing attribute.
Freeze :mod:`zipimport` module into _bootstrap_python
.
Pack debugging location tables more efficiently during bytecode compilation.
Add an internal version number to code objects, to give better versioning of inner functions and comprehensions, and thus better specialization of those functions. This change is invisible to both Python and C extensions.
Improve performance of list.pop
for small lists.
Add :data:`ssl.OP_LEGACY_SERVER_CONNECT`
ctypes
arrays of length 0 now report a correct itemsize when a
memoryview
is constructed from them, rather than always giving a value
of 0.
Speed up :func:`math.fsum` by removing defensive volatile
qualifiers.
Modify :func:`random.choice` implementation to once again work with NumPy arrays.
Add :data:`socket.IP_PKTINFO` constant.
Make :meth:`email.message.Message.__contains__` twice as fast.
Microoptimizations for :meth:`fractions.Fraction.__round__`, :meth:`fractions.Fraction.__ceil__` and :meth:`fractions.Fraction.__floor__`.
Avoid RecursionError on repr
if a dataclass field definition has a
cyclic reference.
Fix crash in :mod:`pyexpat` by statically allocating PyExpat_CAPI
capsule.
Fix unittest.mock.Mock
not respecting the spec for attribute names
prefixed with assert
.
Change SimpleHTTPRequestHandler
to support subclassing to provide a
different set of index file names instead of using __init__
parameters.
Mock
objects which are not unsafe will now raise an AttributeError
when accessing an attribute that matches the name of an assertion but
without the prefix assert_
, e.g. accessing called_once
instead of
assert_called_once
. This is in addition to this already happening for
accessing attributes with prefixes assert
, assret
, asert
,
aseert
, and assrt
.
Simplify and optimize :func:`os.walk` by using :func:`isinstance` checks to check the top of the stack.
Add math.sumprod() to compute the sum of products.
Fix :func:`asyncio.open_connection` to skip binding to local addresses of different family. Patch by Kumar Aditya.
importlib.resources.files
now accepts a module as an anchor instead of
only accepting packages. If a module is passed, resources are resolved
adjacent to that module (in the same package or at the package root). The
parameter was renamed from package
to anchor
with a compatibility
shim for those passing by keyword. Additionally, the new anchor
parameter is now optional and will default to the caller's module.
Fixed a bug where importlib.resources.as_file was leaving file pointers open
Improve performance of :meth:`pathlib.Path.absolute` by nearly 2x. This comes at the cost of a performance regression in :meth:`pathlib.Path.cwd`, which is generally used less frequently in user code.
Small simplification of :func:`http.cookiejar.eff_request_host` that improves readability and better matches the RFC wording.
Fix the interaction of :func:`unittest.mock.seal` with :class:`unittest.mock.AsyncMock`.
Add :meth:`Fraction.is_integer` to check whether a :class:`fractions.Fraction` is an integer. This improves duck type compatibility with :class:`float` and :class:`int`.
:mod:`http.server` now checks that an index page is actually a regular file
before trying to serve it. This avoids issues with directories named
index.html
.
Speed up :func:`asyncio.get_running_loop` by removing redundant getpid
checks. Patch by Kumar Aditya.
Fix crash when creating an instance of :class:`!_ctypes.CField`.
Fix ref cycle in :class:`!asyncio._SelectorSocketTransport` by removing
_read_ready_cb
in close
.
Provide C implementation for :func:`asyncio.current_task` for a 4x-6x speedup.
Fix JSON serialization of OrderedDict. It now preserves the order of keys.
Instantiation of Mock()
and AsyncMock()
is now 3.8x faster.
Set a default value of 1.0 for the lambd
parameter in
random.expovariate().
A :exc:`DeprecationWarning` may be raised when :func:`os.fork()` or :func:`os.forkpty()` is called from multi-threaded processes. Forking with threads is unsafe and can cause deadlocks, crashes and subtle problems. Lack of a warning does not indicate that the fork call was actually safe, as Python may not be aware of all threads.
Improve signatures for enums and flags.
Fix regression in :mod:`asyncio` where a subprocess would sometimes lose data received from pipe.
Fixes inconsistent handling of case sensitivity of extrasaction arg in :class:`csv.DictWriter`.
Fix tuple
subclasses being cast to tuple
when used as enum values.
Rename the fmt parameter of the pure-Python implementation of :meth:`datetime.time.strftime` to format. Rename the t parameter of :meth:`datetime.datetime.fromtimestamp` to timestamp. These changes mean the parameter names in the pure-Python implementation now match the parameter names in the C implementation. Patch by Alex Waygood.
Update :exc:`~urllib.error.HTTPError` to be initialized properly, even if
the fp
is None
. Patch by Dong-hee Na.
Unify error messages in JSON serialization between
json.dumps(float('nan'), allow_nan=False)
and json.dumps(float('nan'),
allow_nan=False, indent=<SOMETHING>)
. Now both include the representation
of the value that could not be serialized.
Fix issue with :func:`os.walk` where a :exc:`RecursionError` would occur on deep directory structures by adjusting the implementation of :func:`os.walk` to be iterative instead of recursive.
Add :ref:`enum-dataclass-support` to the :class:`~enum.Enum` :meth:`~enum.Enum.__repr__`. When inheriting from a :class:`~dataclasses.dataclass`, only show the field names in the value section of the member :func:`repr`, and not the dataclass' class name.
Fix :func:`inspect.getsource` handling of decorator calls with nested parentheses.
Fix .save()
method for LWPCookieJar
and MozillaCookieJar
: saved
file was not truncated on repeated save.
Add :func:`inspect.markcoroutinefunction` decorator which manually marks a function as a coroutine for the benefit of :func:`iscoroutinefunction`.
Add PEP 585 support for :class:`multiprocessing.queues.Queue`.
Remove Jython
partial compatibility code from several stdlib modules.
Fix :mod:`doctest` failure on :class:`types.MethodWrapperType` in modules.
Several improvements to :func:`inspect.signature`'s handling of
__text_signature
. - Fixes a case where :func:`inspect.signature` dropped
parameters - Fixes a case where :func:`inspect.signature` raised
:exc:`tokenize.TokenError` - Allows :func:`inspect.signature` to understand
defaults involving binary operations of constants -
:func:`inspect.signature` is documented as only raising :exc:`TypeError` or
:exc:`ValueError`, but sometimes raised :exc:`RuntimeError`. These cases now
raise :exc:`ValueError` - Removed a dead code path
:mod:`asyncio` is optimized to avoid excessive copying when writing to socket and use :meth:`~socket.socket.sendmsg` if the platform supports it. Patch by Kumar Aditya.
Add missing TCP socket options from Linux: TCP_MD5SIG
,
TCP_THIN_LINEAR_TIMEOUTS
, TCP_THIN_DUPACK
, TCP_REPAIR
,
TCP_REPAIR_QUEUE
, TCP_QUEUE_SEQ
, TCP_REPAIR_OPTIONS
,
TCP_TIMESTAMP
, TCP_CC_INFO
, TCP_SAVE_SYN
, TCP_SAVED_SYN
,
TCP_REPAIR_WINDOW
, TCP_FASTOPEN_CONNECT
, TCP_ULP
,
TCP_MD5SIG_EXT
, TCP_FASTOPEN_KEY
, TCP_FASTOPEN_NO_COOKIE
,
TCP_ZEROCOPY_RECEIVE
, TCP_INQ
, TCP_TX_DELAY
.
Reduced the memory usage of :func:`urllib.parse.unquote` and :func:`urllib.parse.unquote_to_bytes` on large values.
inspect.signature
was raising TypeError
on call with mock objects.
Now it correctly returns (*args, **kwargs)
as infered signature.
Fix a 3.11 regression in :func:`~contextlib.asynccontextmanager`, which caused it to propagate exceptions with incorrect tracebacks and fix a 3.11 regression in :func:`~contextlib.contextmanager`, which caused it to propagate exceptions with incorrect tracebacks for :exc:`StopIteration`.
Deprecate passing more than one positional argument to :meth:`pathlib.PurePath.relative_to` and :meth:`~pathlib.PurePath.is_relative_to`.
Fix reStructuredText syntax errors in docstrings in the :mod:`enum` module.
Optimize the :class:`~fractions.Fraction` arithmetics for small components.
Make :class:`pathlib.PurePath` and :class:`~pathlib.Path` subclassable (private to start). Previously, attempting to instantiate a subclass resulted in an :exc:`AttributeError` being raised. Patch by Barney Gale.
Accept :class:`os.PathLike` (such as :class:`pathlib.Path`) in the
stripdir
arguments of :meth:`compileall.compile_file` and
:meth:`compileall.compile_dir`.
Fix a reference counting issue when a :mod:`ctypes` callback with return
type :class:`~ctypes.py_object` returns None
, which could cause crashes.
Document existing attr
parameter to :func:`curses.window.vline` function
in :mod:`curses`.
Remove claim in documentation that the stripdir
, prependdir
and
limit_sl_dest
parameters of :func:`compileall.compile_dir` and
:func:`compileall.compile_file` could be :class:`bytes`.
Clarify use of octal format of mode argument in help(os.chmod) as well as help(os.fchmod)
Start running SSL tests with OpenSSL 3.1.0-beta1.
The Python test runner (libregrtest) now logs Python build information like "debug" vs "release" build, or LTO and PGO optimizations. Patch by Victor Stinner.
Make two tests forgiving towards host system libexpat with backported security fixes applied.
Removed the --with-system-ffi
configure
option; libffi
must now
always be supplied by the system on all non-Windows platforms. The option
has had no effect on non-Darwin platforms for several releases, and in 3.11
only had the non-obvious effect of invoking pkg-config
to find
libffi
and never setting -DUSING_APPLE_OS_LIBFFI
. Now on Darwin
platforms configure
will first check for the OS libffi
and then fall
back to the same processing as other platforms if it is not found.
Avoid exporting Python symbols in linked Windows applications when the core is built as static.
Allow override of ac_cv_cxx_thread so that cross compiled python can set -pthread for CXX.
Update Windows installer to OpenSSL 1.1.1s
Use _MSVC_LANG >= 202002L
instead of less-precise _MSC_VER >=1929
to
more accurately test for C++20 support in :file:`PC/_wmimodule.cpp`.
Define MS_WIN64
for Mingw-w64 64bit, fix cython compilation failure.
Ensure that :func:`asyncio.Protocol.data_received` receives an immutable :class:`bytes` object (as documented), instead of :class:`bytearray`.
:meth:`winreg.SetValueEx` now leaves the target value untouched in the case
of conversion errors. Previously, -1
would be written in case of such
errors.
hasattr(ctypes.windll, 'nonexistant')
now returns False
instead of
raising :exc:`OSError`.
Update macOS installer to OpenSSL 1.1.1s
Removed obsolete dlfcn.h
shim from the _ctypes
extension module,
which has not been necessary since Mac OS X 10.2.
Fix a bug that caused an :exc:`AttributeError` to be raised in
python-gdb.py
when py-locals
is used without a frame.
Add missing NULL
check for possible allocation failure in *args
parsing in Argument Clinic.
Raising SystemError on import will now have its cause be set to the original unexpected exception.
In argument parsing, after deallocating newly allocated memory, reset its pointer to NULL.
The :c:macro:`Py_CLEAR`, :c:macro:`Py_SETREF` and :c:macro:`Py_XSETREF` macros now only evaluate their arguments once. If an argument has side effects, these side effects are no longer duplicated. Patch by Victor Stinner.