Replaced usage of :func:`tempfile.mktemp` with :class:`~tempfile.TemporaryDirectory` to avoid a potential race condition.
Fix incorrect line numbers while tracing some failed patterns in :ref:`match <match>` statements. Patch by Charles Burkland.
Add auditing events to the :mod:`marshal` module, and stop raising
code.__init__
events for every unmarshalled code object. Directly
instantiated code objects will continue to raise an event, and audit event
handlers should inspect or collect the raw marshal data. This reduces a
significant performance overhead when loading from .pyc
files.
Update the vendored copy of libexpat to 2.4.1 (from 2.2.8) to get the fix for the :cve:`2013-0340` "Billion Laughs" vulnerability. This copy is most used on Windows and macOS.
Made the internal putcmd
function in :mod:`smtplib` sanitize input for
presence of \r
and \n
characters to avoid (unlikely) command
injection.
:mod:`http.client` now avoids infinitely reading potential HTTP headers
after a 100 Continue
status response from the server.
The number of hardware branches per instruction dispatch is reduced from two to one by adding a special instruction for tracing. Patch by Mark Shannon.
Add a deallocator to the bool type to detect refcount bugs in C extensions which call Py_DECREF(Py_True) or Py_DECREF(Py_False) by mistake. Detect also refcount bugs when the empty tuple singleton or the Unicode empty string singleton is destroyed by mistake. Patch by Victor Stinner.
sum() was further optimised for summing up single digit integers.
Update Unicode databases to Unicode 14.0.0.
Fix deepcopying of :class:`types.GenericAlias` objects.
:meth:`int.to_bytes` and :meth:`int.from_bytes` now take a default value of
"big"
for the byteorder
argument. :meth:`int.to_bytes` also takes a
default value of 1
for the length
argument.
Release the GIL while performing isatty
system calls on arbitrary file
descriptors. In particular, this affects :func:`os.isatty`,
:func:`os.device_encoding` and :class:`io.TextIOWrapper`. By extension,
:func:`io.open` in text mode is also affected. This change solves a deadlock
in :func:`os.isatty`. Patch by Vincent Michel in :issue:`44219`.
Added fallback to extension modules with '.sl' suffix on HP-UX
Fix issue where Protocol.__init__
raises RecursionError
when it's
called directly or via super()
. Patch provided by Yurii Karabas.
The deallocator function of the :exc:`BaseException` type now uses the
trashcan mechanism to prevent stack overflow. For example, when a
:exc:`RecursionError` instance is raised, it can be linked to another
RecursionError through the __context__
attribute or the
__traceback__
attribute, and then a chain of exceptions is created. When
the chain is destroyed, nested deallocator function calls can crash with a
stack overflow if the chain is too long compared to the available stack
memory. Patch by Victor Stinner.
Fix PyAiter_Check to only check for the __anext__ presence (not for __aiter__). Rename PyAiter_Check to PyAIter_Check, PyObject_GetAiter -> PyObject_GetAIter.
Interpreter no longer attempts to open files with names in angle brackets (like "<string>" or "<stdin>") when formatting an exception.
Match C and Python code formatting of unprintable exceptions and exceptions in the :mod:`__main__` module.
:func:`open`, :func:`io.open`, :func:`codecs.open` and
:class:`fileinput.FileInput` no longer accept 'U'
("universal newline")
in the file mode. This flag was deprecated since Python 3.3. Patch by Victor
Stinner.
When the interpreter renders an exception, its name now has a complete qualname. Previously only the class name was concatenated to the module name, which sometimes resulted in an incorrect full name being displayed.
(This issue impacted only the C code exception rendering, the :mod:`traceback` module was using qualname already).
List sorting now uses the merge-ordering strategy from Munro and Wild's
powersort()
. Unlike the former strategy, this is provably near-optimal
in the entropy of the distribution of run lengths. Most uses of
list.sort()
probably won't see a significant time difference, but may
see significant improvements in cases where the former strategy was
exceptionally poor. However, as these are all fast linear-time
approximations to a problem that's inherently at best quadratic-time to
solve truly optimally, it's also possible to contrive cases where the former
strategy did better.
Compiler now removes trailing unused constants from co_consts.
Add a new command line option, "-X frozen_modules=[on|off]" to opt out of (or into) using optional frozen modules. This defaults to "on" (or "off" if it's running out of the source tree).
In :mod:`posix`, release GIL during stat()
, lstat()
, and
fstatat()
syscalls made by :func:`os.DirEntry.stat`. Patch by Stanisław
Skonieczny.
Fixed pickling of range iterators that iterated for over 2**32
times.
A :exc:`SyntaxError` is now raised when trying to delete :const:`__debug__`. Patch by Donghee Na.
Implement send()
and throw()
methods for anext_awaitable
objects. Patch by Pablo Galindo.
Fix a race in WeakKeyDictionary, WeakValueDictionary and WeakSet when two threads attempt to commit the last pending removal. This fixes asyncio.create_task and fixes a data loss in asyncio.run where shutdown_asyncgens is not run
Implement the :meth:`__bytes__` special method on the :class:`bytes` type,
so a bytes object b
passes an isinstance(b, typing.SupportsBytes)
check.
Implement the :meth:`__complex__` special method on the :class:`complex`
type, so a complex number z
passes an isinstance(z,
typing.SupportsComplex)
check.
Fixed a corner case bug where the result of float.fromhex('0x.8p-1074')
was rounded the wrong way.
Refine the syntax error for trailing commas in import statements. Patch by Pablo Galindo.
Specialize the BINARY_ADD instruction using the PEP 659 machinery. Adds five new instructions:
- BINARY_ADD_ADAPTIVE
- BINARY_ADD_FLOAT
- BINARY_ADD_INT
- BINARY_ADD_UNICODE
- BINARY_ADD_UNICODE_INPLACE_FAST
Fix some edge cases of enum.Flag
string representation in the REPL.
Patch by Pablo Galindo.
Class version tags are no longer recycled.
This means that a version tag serves as a unique identifier for the state of a class. We rely on this for effective specialization of the LOAD_ATTR and other instructions.
Restore behaviour of complex exponentiation with integer-valued exponent of type :class:`float` or :class:`complex`.
A debug variable :envvar:`PYTHONDUMPREFSFILE` is added for creating a dump file which is generated by :option:`--with-trace-refs`. Patch by Donghee Na.
Add five superinstructions for PEP 659 quickening:
- LOAD_FAST LOAD_FAST
- STORE_FAST LOAD_FAST
- LOAD_FAST LOAD_CONST
- LOAD_CONST LOAD_FAST
- STORE_FAST STORE_FAST
Initial implementation of adaptive specialization of LOAD_METHOD
. The
following specialized forms were added:
LOAD_METHOD_CACHED
LOAD_METHOD_MODULE
LOAD_METHOD_CLASS
Specialization stats are always collected in debug builds.
Correct the ast locations of f-strings with format specs and repeated expressions. Patch by Pablo Galindo
Remove the loop from the bytecode interpreter. All instructions end with a DISPATCH macro, so the loop is now redundant.
Remove switch statement for interpreter loop when using computed gotos. This makes sure that we only have one dispatch table in the interpreter.
Deprecate the old trashcan macros
(Py_TRASHCAN_SAFE_BEGIN
/Py_TRASHCAN_SAFE_END
). They should be
replaced by the new macros Py_TRASHCAN_BEGIN
and Py_TRASHCAN_END
.
Use new trashcan macros (Py_TRASHCAN_BEGIN/END) in frameobject.c instead of the old ones (Py_TRASHCAN_SAFE_BEGIN/END).
Fix segmentation fault with deep recursion when cleaning method objects. Patch by Augusto Goulart and Pablo Galindo.
Fix bug where PyErr_SetObject
hangs when the current exception has a
cycle in its context chain.
Fix reference leaks in the error paths of update_bases()
and
__build_class__
. Patch by Pablo Galindo.
Initial implementation of adaptive specialization of STORE_ATTR
Three specialized forms of STORE_ATTR are added:
- STORE_ATTR_SLOT
- STORE_ATTR_SPLIT_KEYS
- STORE_ATTR_WITH_HINT
Fixed a bug that was causing the parser to raise an incorrect custom :exc:`SyntaxError` for invalid 'if' expressions. Patch by Pablo Galindo.
Create instance dictionaries (__dict__) eagerly, to improve regularity of object layout and assist specialization.
Improve syntax errors for if expressions. Patch by Miguel Brito
Generalize the invalid legacy statement custom error message (like the one generated when "print" is called without parentheses) to include more generic expressions. Patch by Pablo Galindo
Rename types.Union
to types.UnionType
.
Expose specialization stats in python via :func:`!_opcode.get_specialization_stats`.
Improve AttributeError on circular imports of submodules.
Fix undefined behaviour in complex object exponentiation.
Support :mod:`typing` types in parameter substitution in the union type.
Add ability to serialise types.Union
objects. Patch provided by Yurii
Karabas.
Parameter substitution of the union type with wrong types now raises
TypeError
instead of returning :data:`NotImplemented`.
Update property_descr_set
to use vectorcall if possible. Patch by
Donghee Na.
Add __module__
to types.Union
. This also fixes types.Union
issues with typing.Annotated
. Patch provided by Yurii Karabas.
Include the name of the type in unset __slots__ attribute errors. Patch by Pablo Galindo
Don't include a missing attribute with the same name as the failing one when offering suggestions for missing attributes. Patch by Pablo Galindo
Fix the hash of the union type: it no longer depends on the order of arguments.
Collapse union of equal types. E.g. the result of int | int
is now
int
. Fix comparison of the union type with non-hashable objects. E.g.
int | str == {}
no longer raises a TypeError.
On Windows, :func:`os.urandom`: uses BCryptGenRandom API instead of CryptGenRandom API which is deprecated from Microsoft Windows API. Patch by Donghee Na.
Convert None
to type(None)
in the union type constructor.
Implement adaptive specialization for BINARY_SUBSCR
Three specialized forms of BINARY_SUBSCR are added:
- BINARY_SUBSCR_LIST_INT
- BINARY_SUBSCR_TUPLE_INT
- BINARY_SUBSCR_DICT
Mapping patterns in match
statements with two or more equal literal keys
will now raise a :exc:`SyntaxError` at compile-time.
Fix __instancecheck__
and __subclasscheck__
for the union type.
The @classmethod
decorator can now wrap other classmethod-like
descriptors.
Tuned the string-searching algorithm of fastsearch.h to have a shorter inner loop for most cases.
All necessary data for executing a Python function (local variables, stack, etc) is now kept in a per-thread stack. Frame objects are lazily allocated on demand. This increases performance by about 7% on the standard benchmark suite. Introspection and debugging are unaffected as frame objects are always available when needed. Patch by Mark Shannon.
The threading debug (:envvar:`!PYTHONTHREADDEBUG` environment variable) is deprecated in Python 3.10 and will be removed in Python 3.12. This feature requires a debug build of Python. Patch by Victor Stinner.
An obsolete internal cache of shared object file handles added in 1995 that attempted, but did not guarantee, that a .so would not be dlopen'ed twice to work around flaws in mid-1990s posix-ish operating systems has been removed from dynload_shlib.c.
:mod:`typing` now searches for type parameters in types.Union
objects.
get_type_hints
will also properly resolve annotations with nested
types.Union
objects. Patch provided by Yurii Karabas.
Code objects can now provide the column information for instructions when available. This is levaraged during traceback printing to show the expressions responsible for errors.
Contributed by Pablo Galindo, Batuhan Taskaya and Ammar Askar as part of PEP 657.
Remove uses of :c:func:`PyObject_GC_Del` in error path when initializing :class:`types.GenericAlias`.
Fix a memory consumption and copying performance regression in earlier 3.10 beta releases if someone used an output buffer larger than 4GiB with zlib.decompress on input data that expands that large.
Heap types with the :c:macro:`Py_TPFLAGS_IMMUTABLETYPE` flag can now inherit the PEP 590 vectorcall protocol. Previously, this was only possible for :ref:`static types <static-types>`. Patch by Erlend E. Aasland.
Implement GC methods for types.Union
to break reference cycles and
prevent memory leaks.
Add __parameters__
attribute and __getitem__
operator to
types.Union
. Patch provided by Yurii Karabas.
Remove the pass-through for :func:`hash` of :class:`weakref.proxy` objects to prevent unintended consequences when the original referred object dies while the proxy is part of a hashable object. Patch by Pablo Galindo.
Fix a crash in types.Union
objects when creating a union of an object
with bad __module__
field.
Modules will always have a dictionary, even when created by
types.ModuleType.__new__()
Fix ltrace functionality when exceptions are raised. Patch by Pablo Galindo
A :exc:`TypeError` is now raised instead of an :exc:`AttributeError` in :keyword:`with` and :keyword:`async with` statements for objects which do not support the :term:`context manager` or :term:`asynchronous context manager` protocols correspondingly.
Make sure that the line number is set when entering a comprehension scope. This ensures that backtraces including generator expressions show the correct line number.
Improve the syntax error when mixing positional and keyword patterns. Patch by Pablo Galindo.
Fix error location information for tokenizer errors raised on initialization of the tokenizer. Patch by Pablo Galindo.
Fix a possible crash in the tokenizer when raising syntax errors for unclosed strings. Patch by Pablo Galindo.
Exact integer exponentiation (like i**2
or pow(i, 2)
) with a small
exponent is much faster, due to reducing overhead in such cases.
Directly imported objects and modules (through import and from import
statements) don't generate LOAD_METHOD
/CALL_METHOD
for directly
accessed objects on their namespace. They now use the regular
LOAD_ATTR
/CALL_FUNCTION
.
Implement adaptive specialization for LOAD_GLOBAL
Two specialized forms of LOAD_GLOBAL are added:
- LOAD_GLOBAL_MODULE
- LOAD_GLOBAL_BUILTIN
Improve syntax errors for invalid "as" targets. Patch by Pablo Galindo
Fix an edge case when displaying text from files with encoding in syntax errors. Patch by Pablo Galindo.
Initial implementation of adaptive specialization of LOAD_ATTR
Four specialized forms of LOAD_ATTR are added:
- LOAD_ATTR_SLOT
- LOAD_ATTR_SPLIT_KEYS
- LOAD_ATTR_WITH_HINT
- LOAD_ATTR_MODULE
Fix a regression when identifying incorrect characters in syntax errors. Patch by Pablo Galindo
Computation of the offsets of cell variables is done in the compiler instead of at runtime. This reduces the overhead of handling cell and free variables, especially in the case where a variable is both an argument and cell variable.
Improve tokenizer error with improved locations. Patch by Pablo Galindo.
Fix a crash in the :mod:`sqlite3` module that happened when the garbage collector clears :class:`sqlite.Statement` objects. Patch by Pablo Galindo
Improve error message for try
blocks without except
or finally
blocks. Patch by Pablo Galindo.
Constructors of subclasses of some builtin classes (e.g. :class:`tuple`,
:class:`list`, :class:`frozenset`) no longer accept arbitrary keyword
arguments. [reverted in 3.11a4] Subclass of :class:`set` can now define a __new__()
method
with additional keyword parameters without overriding also __init__()
.
Improve Unicode support in non-UTF locales on Oracle Solaris. This issue does not affect other Solaris systems.
A new opcode MAKE_CELL has been added that effectively moves some of the work done on function entry into the compiler and into the eval loop. In addition to creating the required cell objects, the new opcode converts relevant arguments (and other locals) to cell variables on function entry.
Fix a regression in :func:`type` when a metaclass raises an exception. The C function :c:func:`type_new` must properly report the exception when a metaclass constructor raises an exception and the winner class is not the metaclass. Patch by Victor Stinner.
Avoid side effects of checking for specialized syntax errors in the REPL that was causing it to ask for extra tokens after a syntax error had been detected. Patch by Pablo Galindo
PyCodeObject
gained co_fastlocalnames
and co_fastlocalkinds
as
the authoritative source of fast locals info. Marshaled code objects
have changed accordingly.
Fix a crash at Python exit when a deallocator function removes the last strong reference to a heap type. Patch by Victor Stinner.
Implement quickening in the interpreter. This offers no advantages as yet, but is an enabler of future optimizations. See PEP 659 for full explanation.
The parser doesn't report generic syntax errors that happen in a position further away that the one it reached in the first pass. Patch by Pablo Galindo
Fix error message in the parser involving keyword arguments with invalid expressions. Patch by Pablo Galindo
String caches in compile.c
are now subinterpreter compatible.
Fixed a crash in the parser that manifest when raising tokenizer errors when an existing exception was present. Patch by Pablo Galindo.
Move 'fast' locals and other variables from the frame object to a per-thread datastack.
Fix incorrect dictkeys_reversed and dictitems_reversed function signatures in C code, which broke webassembly builds.
Improve :func:`str.__getitem__` error message
Add CALL_METHOD_KW
opcode to speed up method calls with keyword
arguments. Idea originated from PyPy. A side effect is executing
CALL_METHOD
is now branchless in the evaluation loop.
Compiler now optimizes simple C-style formatting with literal format containing only format codes %s, %r and %a by converting them to f-string expressions.
Correct the syntax error message regarding multiple exception types to not refer to "exception groups". Patch by Pablo Galindo
The parser will prioritize tokenizer errors over custom syntax errors when raising exceptions. Patch by Pablo Galindo.
"Zero cost" exception handling.
- Uses a lookup table to determine how to handle exceptions.
- Removes SETUP_FINALLY and POP_TOP block instructions, eliminating the runtime overhead of try statements.
- Reduces the size of the frame object by about 60%.
Patch by Mark Shannon
Document the signature and default
argument in the docstring of the new
anext
builtin.
Emit a deprecation warning if the numeric literal is immediately followed by one of keywords: and, else, for, if, in, is, or. Raise a syntax error with more informative message if it is immediately followed by other keyword or identifier.
Add native_thread_id to PyThreadState. Patch by Gabriele N. Tornetta.
Compute cell offsets relative to locals in compiler. Allows the interpreter to treats locals and cells a single array, which is slightly more efficient. Also make the LOAD_CLOSURE opcode an alias for LOAD_FAST. Preserving LOAD_CLOSURE helps keep bytecode a bit more readable.
More accurate error messages for access of unbound locals or free vars.
Fix a confusing error message in :func:`str.format`.
When compiling :class:`ast.AST` objects with recursive references through :func:`compile`, the interpreter doesn't crash anymore instead it raises a :exc:`RecursionError`.
Fix crash when using passing a non-exception to a generator's throw()
method. Patch by Noah Oxer
Asynchronous comprehensions are now allowed inside comprehensions in asynchronous functions. Outer comprehensions implicitly become asynchronous.
Fix clang rpath issue in distutils
. The UnixCCompiler now uses
correct clang option to add a runtime library directory (rpath) to a shared
library.
Fix freed memory access in :class:`pyexpat.xmlparser` when building it with an installed expat library <= 2.2.0.
On Unix, if the sem_clockwait()
function is available in the C library
(glibc 2.30 and newer), the :meth:`threading.Lock.acquire` method now uses
the monotonic clock (:const:`time.CLOCK_MONOTONIC`) for the timeout, rather
than using the system clock (:const:`time.CLOCK_REALTIME`), to not be
affected by system clock changes. Patch by Victor Stinner.
Fix the :func:`threading._shutdown` function when the :mod:`threading` module was imported first from a thread different than the main thread: no longer log an error at Python exit.
Fix a race condition in the :meth:`Thread.join() <threading.Thread.join>` method of the :mod:`threading` module. If the function is interrupted by a signal and the signal handler raises an exception, make sure that the thread remains in a consistent state to prevent a deadlock. Patch by Victor Stinner.
In Unix operating systems, :func:`time.sleep` now uses the nanosleep()
function, if clock_nanosleep()
is not available but nanosleep()
is
available. nanosleep()
allows to sleep with nanosecond precision.
On Windows, :func:`time.sleep` now uses a waitable timer which has a resolution of 100 nanoseconds (10-7 seconds). Previously, it had a resolution of 1 millisecond (10-3 seconds). Patch by Benjamin Szőke and Victor Stinner.
Fix :meth:`unittest.IsolatedAsyncioTestCase.debug`: it runs now asynchronous methods and callbacks.
:meth:`unittest.TestCase.debug` raises now a :class:`unittest.SkipTest` if the class or the test method are decorated with the skipping decorator.
Fix an issue where argparse would not preserve values in a provided namespace when using a subparser with defaults.
Have zipimport.zipimporter.find_spec() not raise an exception when the underlying zip file has been deleted and the internal cache has been reset via invalidate_cache().
Fixed a regression in :func:`~shutil.copyfile`, :func:`~shutil.copy`, :func:`~shutil.copy2` raising :exc:`FileNotFoundError` when source is a directory, which should raise :exc:`IsADirectoryError`
Fix stack buffer overflow in parsing J1939 network address.
use map function instead of genexpr in capwords.
Fix typo: importlib.find_loader
is really slated for removal in Python
3.12 not 3.10, like the others in PR 25169.
Patch by Hugo van Kemenade.
Improves error messages on .format()
operation for str
, float
,
int
, and complex
. New format now shows the problematic pattern and
the object type.
Change :func:`dis.dis` output to omit op arg values that cannot be resolved
due to co_consts
, co_names
etc not being provided. Previously the
oparg itself was repeated in the value field, which is not useful and can be
confusing.
In Unix operating systems, :func:`time.sleep` now uses the
clock_nanosleep()
function, if available, which allows to sleep for an
interval specified with nanosecond precision.
Remove from the :mod:`configparser` module: the :class:`!SafeConfigParser` class, the :attr:`!filename` property of the :class:`~configparser.ParsingError` class, the :meth:`!readfp` method of the :class:`~configparser.ConfigParser` class, deprecated since Python 3.2.
Patch by Hugo van Kemenade.
Pure ASCII strings are now normalized in constant time by :func:`unicodedata.normalize`. Patch by Donghee Na.
Calling :func:`mimetypes.guess_all_extensions` with strict=False
no
longer affects the result of the following call with strict=True
. Also,
mutating the returned list no longer affects the global state.
:func:`typing.get_type_hints` now works with :data:`~typing.Final` wrapped in :class:`~typing.ForwardRef`.
Remove many old deprecated :mod:`unittest` features:
- "
fail*
" and "assert*
" aliases of :class:`~unittest.TestCase` methods. - Broken from start :class:`~unittest.TestCase` method
assertDictContainsSubset()
. - Ignored :meth:`<unittest.TestLoader.loadTestsFromModule> TestLoader.loadTestsFromModule` parameter use_load_tests.
- Old alias
_TextTestResult
of :class:`~unittest.TextTestResult`.
Remove the deprecated split()
method of :class:`!_tkinter.TkappType`.
Patch by Erlend E. Aasland.
Improve the speed and accuracy of statistics.pvariance().
Remove :meth:`~object.__getitem__` methods of :class:`xml.dom.pulldom.DOMEventStream`, :class:`wsgiref.util.FileWrapper` and :class:`fileinput.FileInput`, deprecated since Python 3.9.
Patch by Hugo van Kemenade.
Due to significant security concerns, the reuse_address parameter of
:meth:`asyncio.loop.create_datagram_endpoint`, disabled in Python 3.9, is
now entirely removed. This is because of the behavior of the socket option
SO_REUSEADDR
in UDP.
Patch by Hugo van Kemenade.
The bdist_msi
command, deprecated in Python 3.9, is now removed.
Use bdist_wheel
(wheel packages) instead.
Patch by Hugo van Kemenade.
:class:`unittest.TestResult` methods :meth:`~unittest.TestResult.addFailure`, :meth:`~unittest.TestResult.addError`, :meth:`~unittest.TestResult.addSkip` and :meth:`~unittest.TestResult.addSubTest` are now called immediately after raising an exception in test or finishing a subtest. Previously they were called only after finishing the test clean up.
Changes how error is formatted for struct.pack
with 'H'
and 'h'
modes and too large / small numbers. Now it shows the actual numeric limits,
while previously it was showing arithmetic expressions.
:mod:`unittest` now always reports skipped and failed subtests separately: separate characters in default mode and separate lines in verbose mode. Also the test description is now output for errors in test method, class and module cleanups.
Fix issue when dataclasses that inherit from typing.Protocol
subclasses
have wrong __init__
. Patch provided by Yurii Karabas.
The binhex
module, deprecated in Python 3.9, is now removed. The
following :mod:`binascii` functions, deprecated in Python 3.9, are now also
removed:
a2b_hqx()
,b2a_hqx()
;rlecode_hqx()
,rledecode_hqx()
.
The :func:`binascii.crc_hqx` function remains available.
Patch by Victor Stinner.
The :mod:`!lib2to3` package is now deprecated and may not be able to parse Python 3.10 or newer. See the PEP 617 (New PEG parser for CPython). Patch by Victor Stinner.
Rename :meth:`traceback.StackSummary.format_frame` to :meth:`traceback.StackSummary.format_frame_summary`. This method was added for 3.11 so it was not released yet.
Updated code and docs to better distinguish frame and FrameSummary.
Add option to completely drop frames from a traceback by returning None
from a :meth:`~traceback.StackSummary.format_frame` override.
:meth:`~unittest.TestCase.run` now always return a
:class:`~unittest.TestResult` instance. Previously it returned None
if
the test class or method was decorated with a skipping decorator.
Fix a potential deadlock at shutdown of forked children when using :mod:`concurrent.futures` module
Fix bugs in cleaning up classes and modules in :mod:`unittest`:
- Functions registered with :func:`~unittest.addModuleCleanup` were not called unless the user defines
tearDownModule()
in their test module. - Functions registered with :meth:`~unittest.TestCase.addClassCleanup` were not called if
tearDownClass
is set toNone
. - Buffering in :class:`~unittest.TestResult` did not work with functions registered with
addClassCleanup()
andaddModuleCleanup()
. - Errors in functions registered with
addClassCleanup()
andaddModuleCleanup()
were not handled correctly in buffered and debug modes. - Errors in
setUpModule()
and functions registered withaddModuleCleanup()
were reported in wrong order. - And several lesser bugs.
Fix integer overflow in pickling and copying the range iterator.
Made email date parsing more robust against malformed input, namely a
whitespace-only Date:
header. Patch by Wouter Bolsterlee.
Remove support of special method __div__
in :mod:`unittest.mock`. It is
not used in Python 3.
Improve accuracy of variance calculations by using x*x
instead of
x**2
.
Improve the speed of :func:`gzip.compress` and :func:`gzip.decompress` by compressing and decompressing at once in memory instead of in a streamed fashion.
Ensure that :class:`set` and :class:`frozenset` objects are always :mod:`marshalled <marshal>` reproducibly.
A new function operator.call
has been added, such that
operator.call(obj, *args, **kwargs) == obj(*args, **kwargs)
.
:class:`!webbrowser.MacOSX` is deprecated and will be removed in Python 3.13. It is untested and undocumented and also not used by :mod:`webbrowser` itself. Patch by Donghee Na.
Method :meth:`~unittest.TestResult.stopTestRun` is now always called in pair with method :meth:`~unittest.TestResult.startTestRun` for :class:`~unittest.TestResult` objects implicitly created in :meth:`~unittest.TestCase.run`. Previously it was not called for test methods and classes decorated with a skipping decorator.
tarfile.open raises :exc:`~tarfile.ReadError` when a zlib error occurs during file extraction.
:mod:`subprocess` on Solaris now also uses :func:`os.posix_spawn` for better performance.
:class:`~unittest.IsolatedAsyncioTestCase` will no longer throw an exception while cancelling leaked tasks. Patch by Bar Harel.
Added DeprecationWarning
for tests and async tests that return a
value!=None (as this may indicate an improperly written test, for example a
test written as a generator function).
Make exception message more useful when subclass from typing special form alias. Patch provided by Yurii Karabas.
:class:`argparse.BooleanOptionalAction`'s default value is no longer printed twice when used with :class:`argparse.ArgumentDefaultsHelpFormatter`.
Fix the posix_user
scheme in :mod:`sysconfig` to not depend on
:data:`sys.platlibdir`.
Improve error handling in :mod:`sqlite3` and raise more accurate exceptions.
- :exc:`MemoryError` is now raised instead of :exc:`sqlite3.Warning` when memory is not enough for encoding a statement to UTF-8 in
Connection.__call__()
andCursor.execute()
. - :exc:`UnicodEncodeError` is now raised instead of :exc:`sqlite3.Warning` when the statement contains surrogate characters in
Connection.__call__()
andCursor.execute()
. - :exc:`TypeError` is now raised instead of :exc:`ValueError` for non-string script argument in
Cursor.executescript()
. - :exc:`ValueError` is now raised for script containing the null character instead of truncating it in
Cursor.executescript()
. - Correctly handle exceptions raised when getting boolean value of the result of the progress handler.
- Add many tests covering different corner cases.
Upgrade bundled pip to 21.2.3 and setuptools to 57.4.0
Fix the :func:`os.set_inheritable` function on FreeBSD 14 for file
descriptor opened with the :const:`~os.O_PATH` flag: ignore the
:const:`~errno.EBADF` error on ioctl()
, fallback on the fcntl()
implementation. Patch by Victor Stinner.
The @functools.total_ordering() decorator now works with metaclasses.
Fixed an issue wherein the __name__
and __qualname__
attributes of
subscribed specialforms could be None
.
:class:`MemoryError` raised in user-defined functions will now produce a
MemoryError
in :mod:`sqlite3`. :class:`OverflowError` will now be
converted to :class:`~sqlite3.DataError`. Previously
:class:`~sqlite3.OperationalError` was produced in these cases.
:mod:`sqlite3` user-defined functions and aggregators returning :class:`strings <str>` with embedded NUL characters are no longer truncated. Patch by Erlend E. Aasland.
Ensure that the :class:`~typing.ParamSpec` variable in Callable can only be substituted with a parameters expression (a list of types, an ellipsis, ParamSpec or Concatenate).
Non-protocol subclasses of :class:`typing.Protocol` ignore now the
__init__
method inherited from protocol base classes.
:meth:`collections.OrderedDict.popitem` and
:meth:`collections.OrderedDict.pop` no longer call __getitem__
and
__delitem__
methods of the OrderedDict subclasses.
Fix checking the number of arguments when subscribe a generic type with
ParamSpec
parameter.
In importlib.metadata tests, override warnings behavior under expected DeprecationWarnings (importlib_metadata 4.6.3).
The :func:`tokenize.tokenize` doesn't incorrectly generate a NEWLINE
token if the source doesn't end with a new line character but the last line
is a comment, as the function is already generating a NL
token. Patch by
Pablo Galindo
Added importlib.simple
module implementing adapters from a low-level
resources reader interface to a TraversableResources
interface. Legacy
API (path
, contents
, ...) is now supported entirely by the
.files()
API with a compatibility shim supplied for resource loaders
without that functionality. Feature parity with importlib_resources
5.2.
:mod:`rcompleter` does not call :func:`getattr` on :class:`property` objects to avoid the side-effect of evaluating the corresponding method.
Refactor usage of sys._getframe
in typing
module. Patch provided by
Yurii Karabas.
Fixes the issue with log file being overwritten when
:class:`logging.FileHandler` is used in :mod:`atexit` with filemode set to
'w'
. Note this will cause the message in atexit not being logged if
the log stream is already closed due to shutdown of logging.
weakref.proxy
objects referencing non-iterators now raise TypeError
rather than dereferencing the null tp_iternext
slot and crashing.
The implementation of collections.abc.Set._hash()
now matches that of
frozenset.__hash__()
.
Fixed issue in :func:`compileall.compile_file` when sys.stdout
is
redirected. Patch by Stefan Hölzl.
:meth:`sqlite3.Connection.create_collation` now accepts non-ASCII collation names. Patch by Erlend E. Aasland.
Adopt binacii.a2b_base64's strict mode in base64.b64decode.
Fixed a bug in the :mod:`!_ssl` module that was throwing :exc:`OverflowError`
when using :meth:`!_ssl._SSLSocket.write` and :meth:`!_ssl._SSLSocket.read`
for a big value of the len
parameter. Patch by Pablo Galindo.
Replace unittest.mock._importer
with pkgutil.resolve_name
.
Make NewType.__call__
faster by implementing it in C. Patch provided by
Yurii Karabas.
Change the :mod:`pdb` commands directive to disallow setting commands for an invalid breakpoint and to display an appropriate error.
Refactor typing.NewType
from function into callable class. Patch
provided by Yurii Karabas.
Added a separate error message for discontinuous padding in binascii.a2b_base64 strict mode.
Add missing __name__
and __qualname__
attributes to typing
module classes. Patch provided by Yurii Karabas.
Give priority to using the current class constructor in :func:`inspect.signature`. Patch by Weipeng Hong.
Add a reference to the zipp project and hint as to how to use it.
Fixed wrong error being thrown by :func:`inspect.getsource` when examining a class in the interactive session. Instead of :exc:`TypeError`, it should be :exc:`OSError` with appropriate error message.
Fix memory leak in :func:`!_tkinter._flatten` if it is called with a sequence or set, but not list or tuple.
Fix an edge case of :class:`ExitStack` and :class:`AsyncExitStack` exception
chaining. They will now match with
block behavior when __context__
is explicitly set to None
when the exception is in flight.
In :mod:`fnmatch`, the cache size for compiled regex patterns (:func:`functools.lru_cache`) was bumped up from 256 to 32768, affecting functions: :func:`fnmatch.fnmatch`, :func:`fnmatch.fnmatchcase`, :func:`fnmatch.filter`.
Update :func:`shutil.copyfile` to raise :exc:`FileNotFoundError` instead of confusing :exc:`IsADirectoryError` when a path ending with a :const:`os.path.sep` does not exist; :func:`shutil.copy` and :func:`shutil.copy2` are also affected.
Added the :func:`StackSummary.format_frame` function in :mod:`traceback`. This allows users to customize the way individual lines are formatted in tracebacks without re-implementing logic to handle recursive tracebacks.
handle StopIteration subclass raised from @contextlib.contextmanager generator
Make the implementation consistency of :func:`~operator.indexOf` between C and Python versions. Patch by Donghee Na.
Fixes TypedDict
to work with typing.get_type_hints()
and postponed
evaluation of annotations across modules.
Refactor argument processing in :func:`pdb.main` to simplify detection of errors in input loading and clarify behavior around module or script invocation.
Break up paragraph about :class:`pprint.PrettyPrinter` construction parameters to make it easier to read.
Added support for recognizing JPEG files without JFIF or Exif markers.
Fix bug with :mod:`pdb`'s handling of import error due to a package which
does not have a __main__
module
Fix a bug in the detection of CSV file headers by :meth:`csv.Sniffer.has_header` and improve documentation of same.
Update vendored pip to 21.1.3
Fixed an exception thrown while parsing a malformed multipart email by :class:`email.message.EmailMessage`.
:func:`typing.get_type_hints` now finds annotations in classes and base
classes with unexpected __module__
. Previously, it skipped those MRO
elements.
Allow clearing the :mod:`sqlite3` authorizer callback by passing :const:`None` to :meth:`~sqlite3.Connection.set_authorizer`. Patch by Erlend E. Aasland.
Set the proper :c:macro:`Py_TPFLAGS_MAPPING` and :c:macro:`Py_TPFLAGS_SEQUENCE` flags for subclasses created before a parent has been registered as a :class:`collections.abc.Mapping` or :class:`collections.abc.Sequence`.
Fix very unlikely resource leak in :mod:`glob` in alternate Python implementations.
The :mod:`faulthandler` module now detects if a fatal error occurs during a garbage collector collection. Patch by Victor Stinner.
A :exc:`TypeError` is now raised instead of an :exc:`AttributeError` in :meth:`contextlib.ExitStack.enter_context` and :meth:`contextlib.AsyncExitStack.enter_async_context` for objects which do not support the :term:`context manager` or :term:`asynchronous context manager` protocols correspondingly.
:mod:`tkinter`'s after()
method now supports callables without the
__name__
attribute.
Make :mod:`pprint` (like the builtin print
) not attempt to write to
stdout
when it is None
.
BUFFER_BLOCK_SIZE
is now declared static, to avoid linking collisions
when bz2, lmza or zlib are statically linked.
Remove exception for flake8 in deprecated importlib.metadata interfaces. Sync with importlib_metadata 4.6.
Take into account that lineno
might be None
in
:class:`traceback.FrameSummary`.
Fix in :meth:`bz2.BZ2File.write` / :meth:`lzma.LZMAFile.write` methods, when the input data is an object that supports the buffer protocol, the file length may be wrong.
_thread.start_new_thread() no longer calls PyThread_exit_thread() explicitly at the thread exit, the call was redundant. On Linux with the glibc, pthread_exit() aborts the whole process if dlopen() fails to open libgcc_s.so file (ex: EMFILE error). Patch by Victor Stinner.
The _thread.RLock type now fully implement the GC protocol: add a traverse function and the :c:macro:`Py_TPFLAGS_HAVE_GC` flag. Patch by Victor Stinner.
The :func:`threading.enumerate` function now uses a reentrant lock to prevent a hang on reentrant call. Patch by Victor Stinner.
Importing typing.io or typing.re now prints a DeprecationWarning
.
argparse actions store_const and append_const each receive a default value
of None
when the const
kwarg is not provided. Previously, this raised a
:exc:`TypeError`.
Fix deprecation of :data:`ssl.OP_NO_TLSv1_3`
:meth:`pathlib.PureWindowsPath.is_reserved` now identifies a greater range of reserved filenames, including those with trailing spaces or colons.
Fix :meth:`~email.message.MIMEPart.as_string` to pass unixfrom properly. Patch by Donghee Na.
Handle exceptions from parsing the arg of :mod:`pdb`'s run/restart command.
Improve :mod:`ssl` module's deprecation messages, error reporting, and documentation for deprecations.
[Enum] Change pickling from by-value to by-name.
[Enum] Allow multiple data-type mixins if they are all the same.
Restore back :func:`parse_makefile` in distutils.sysconfig
because it
behaves differently than the similar implementation in :mod:`sysconfig`.
:class:`!smtpd.MailmanProxy` is now removed as it is unusable without an
external module, mailman
. Patch by Donghee Na.
Added a function that returns cube root of the given number :func:`math.cbrt`
Change math.pow(±0.0, -math.inf)
to return inf
instead of raising
ValueError
. This brings the special-case handling of math.pow
into
compliance with the IEEE 754 standard.
Remove missing flag check from Enum creation and move into a verify
decorator.
In importlib.metadata
, restore compatibility in the result from
Distribution.entry_points
(EntryPoints
) to honor expectations in
older implementations and issuing deprecation warnings for these cases: A.
EntryPoints
objects are once again mutable, allowing for sort()
and other list-based mutation operations. Avoid deprecation warnings by
casting to a mutable sequence (e.g. list(dist.entry_points).sort()
).
B. EntryPoints
results once again allow for access by index. To avoid
deprecation warnings, cast the result to a Sequence first (e.g.
tuple(dist.entry_points)[0]
).
In importlib.metadata.entry_points, de-duplication of distributions no longer requires loading the full metadata for PathDistribution objects, improving entry point loading performance by ~10x.
Added a function that returns a copy of a dict of logging levels: :func:`logging.getLevelNamesMapping`
The :class:`random.Random` constructor no longer reads system entropy without need.
On Mac, give turtledemo button text a color that works on both light or dark background. Programmers cannot control the latter.
Support PEP 515 for Fraction's initialization from string.
Remove deprecated functions in the :mod:`gettext`. Patch by Donghee Na.
Prefer f-strings to .format
in importlib.resources.
Importlib.metadata now prefers f-strings to .format.
Incorporate minor tweaks from importlib_metadata 4.1: SimplePath protocol, support for Metadata 2.2.
Remove the :func:`@asyncio.coroutine <asyncio.coroutine>` :term:`decorator` enabling legacy generator-based coroutines to be compatible with async/await code; remove :class:`asyncio.coroutines.CoroWrapper` used for wrapping legacy coroutine objects in the debug mode. The decorator has been deprecated since Python 3.8 and the removal was initially scheduled for Python 3.10. Patch by Illia Volochii.
Make importlib.metadata._meta.PackageMetadata public.
Declare readers.MultiplexedPath.name as a property per the spec.
The :mod:`sqlite3` context manager now performs a rollback (thus releasing the database lock) if commit failed. Patch by Luca Citi and Erlend E. Aasland.
Documented existing behavior on POSIX: NamedTemporaryFiles are not deleted when creating process is killed with SIGKILL
Optimize :class:`fractions.Fraction` pickling for large components.
For IPv4 mapped IPv6 addresses (RFC 4291 Section 2.5.5.2), the :mod:`ipaddress.IPv6Address.is_private` check is deferred to the mapped IPv4 address. This solves a bug where public mapped IPv4 addresses were considered private by the IPv6 check.
Add optional weights argument to statistics.fmean().
:func:`ast.unparse` will now drop the redundant parentheses when tuples used as assignment targets (e.g in for loops).
:mod:`hmac` computations were not releasing the GIL while calling the
OpenSSL HMAC_Update
C API (a new feature in 3.9). This unintentionally
prevented parallel computation as other :mod:`hashlib` algorithms support.
:class:`zipfile.Path` now supports :attr:`zipfile.Path.stem`, :attr:`zipfile.Path.suffixes`, and :attr:`zipfile.Path.suffix` attributes.
It's now possible to receive the type of service (ToS), a.k.a.
differentiated services (DS), a.k.a. differentiated services code point
(DSCP) and explicit congestion notification (ECN) IP header fields with
socket.IP_RECVTOS
.
Fix a reference leak when a Thread object is never joined.
Subclasses of typing.Protocol
which only have data variables declared
will now raise a TypeError
when checked with isinstance
unless they
are decorated with :func:`runtime_checkable`. Previously, these checks
passed silently. Patch provided by Yurii Karabas.
typing.ParamSpec
will no longer be found in the __parameters__
of
most :mod:`typing` generics except in valid use locations specified by
PEP 612. This prevents incorrect usage like typing.List[P][int]
. This
change means incorrect usage which may have passed silently in 3.10 beta 1
and earlier will now error.
Allow subclassing csv.Error
in 3.10 (it was allowed in 3.9 and earlier
but was disallowed in early versions of 3.10).
:func:`ast.unparse` now doesn't use redundant spaces to separate lambda
and the :
if there are no parameters.
Fix regression in previous release when calling :func:`pkgutil.iter_modules` with a list of :class:`pathlib.Path` objects
Register the SerenityOS Browser in the :mod:`webbrowser` module.
The :mod:`hashlib` module no longer does unaligned memory accesses when compiled for ARM platforms.
Remove random module features deprecated in Python 3.9.
random.seed() no longer mutates bytearray inputs.
Add IO
, BinaryIO
, TextIO
, Match
, and Pattern
to
typing.__all__
. Patch by Jelle Zijlstra.
:mod:`urllib.parse` now uses :func:`functool.lru_cache` for its internal URL splitting and quoting caches instead of rolling its own like its the '90s.
The undocumented internal :mod:`urllib.parse` Quoted
class API is now
deprecated, for removal in 3.14.
When :class:`http.server.SimpleHTTPRequestHandler` sends a 301 (Moved
Permanently)
for a directory path not ending with /
, add a
Content-Length: 0
header. This improves the behavior for certain
clients.
Fix a bug in :mod:`pdb` where :meth:`~pdb.Pdb.checkline` raises :exc:`AttributeError` if it is called after :meth:`~pdb.Pdb.reset`.
Improved string handling for :mod:`sqlite3` user-defined functions and aggregates:
- It is now possible to pass strings with embedded null characters to UDFs
- Conversion failures now correctly raise :exc:`MemoryError`
Patch by Erlend E. Aasland.
AIX: Lib/_aix_support.get_platform()
may fail in an AIX WPAR. The fileset
bos.rte appears to have a builddate in both LPAR and WPAR so this fileset is
queried rather than bos.mp64. To prevent a similar situation (no builddate
in ODM) a value (9988) sufficient for completing a build is provided. Patch
by M Felt.
Fix :exc:`MemoryError` in :func:`shutil.unpack_archive` which fails inside :func:`shutil._unpack_zipfile` on large files. Patch by Igor Bolshakov.
:func:`zlib.compress` now accepts a wbits parameter which allows users to
compress data as a raw deflate block without zlib headers and trailers in
one go. Previously this required instantiating a zlib.compressobj
. It
also provides a faster alternative to gzip.compress
when wbits=31 is
used.
:func:`importlib._bootstrap._find_and_load` now implements a two-step check to avoid locking when modules have been already imported and are ready. This improves performance of repeated calls to :func:`importlib.import_module` and :func:`importlib.__import__`.
Fix a bug where :mod:`pdb` does not always echo cleared breakpoints.
Prohibit passing non-:class:`concurrent.futures.ThreadPoolExecutor` executors to :meth:`loop.set_default_executor` following a deprecation in Python 3.8. Patch by Illia Volochii.
Prohibit previously deprecated potentially disruptive operations on :class:`asyncio.trsock.TransportSocket`. Patch by Illia Volochii.
Added support for Apple's aifc/sowt pseudo-compression
Add definition of errno.EQFULL
for platforms that define this constant
(such as macOS).
Added a new optional strict_mode
parameter to binascii.a2b_base64.
When scrict_mode
is set to True
, the a2b_base64 function
will accept only valid base64 content. More details about what "valid base64
content" is, can be found in the function's documentation.
Improve the help signature of :func:`traceback.print_exception`, :func:`traceback.format_exception` and :func:`traceback.format_exception_only`.
Add the :meth:`traceback.TracebackException.print` method which prints the formatted exception information.
:mod:`sqlite3` now utilizes :meth:`functools.lru_cache` to implement the connection statement cache. As a small optimisation, the default statement cache size has been increased from 100 to 128. Patch by Erlend E. Aasland.
Soumendra Ganguly: add termios.tcgetwinsize(), termios.tcsetwinsize().
:meth:`subprocess.check_output` now raises :exc:`ValueError` when the invalid keyword argument check is passed by user code. Previously such use would fail later with a :exc:`TypeError`. Patch by Rémi Lapeyre.
ensurepip
now uses importlib.resources.files()
traversable APIs
Use Argument Clinic in :mod:`sqlite3`. Patches by Erlend E. Aasland.
DeprecationWarning
is now raised when importing :mod:`tkinter.tix`,
which has been deprecated in documentation since Python 3.6.
Remove unused _signature_get_bound_param
function from :mod:`inspect` -
by Anthony Sottile.
Fix :meth:`email.message.EmailMessage.set_content` when called with binary
data and 7bit
content transfer encoding.
The compresslevel and preset keyword arguments of :func:`tarfile.open` are now both documented and tested.
Use utf-8 encoding while reading .pdbrc files. Patch by Srinivas Reddy Thatiparthy
Improved reprs of :mod:`threading` synchronization objects: :class:`~threading.Semaphore`, :class:`~threading.BoundedSemaphore`, :class:`~threading.Event` and :class:`~threading.Barrier`.
Deprecated the following :mod:`unittest` functions, scheduled for removal in Python 3.13:
Use :class:`~unittest.TestLoader` methods instead:
- :meth:`unittest.TestLoader.loadTestsFromModule`
- :meth:`unittest.TestLoader.loadTestsFromTestCase`
- :meth:`unittest.TestLoader.getTestCaseNames`
Patch by Erlend E. Aasland.
Support pathlike objects on dbm/shelve. Patch by Hakan Çelik and Henry-Joseph Audéoud.
Fixed a Y2k38 bug in the compileall module where it would fail to compile files with a modification time after the year 2038.
Whereas the code for reprlib.Repr had previously used a hardcoded string value of '...', this PR updates it to use of a “fillvalue” attribute, whose value defaults to '...' and can be reset in either individual reprlib.Repr instances or in subclasses thereof.
:mod:`pdb` now displays exceptions from repr()
with its p
and pp
commands.
Fix test___all__
on platforms lacking a shared memory implementation.
Add one missing check that the password is a bytes object for an encrypted zipfile.
:mod:`configparser`: using ']' inside a section header will no longer cut the section name short at the ']'
Added missing behavior to :func:`contextlib.asynccontextmanager` to match :func:`contextlib.contextmanager` so decorated functions can themselves be decorators.
Pass multiprocessing BaseProxy argument manager_owned
through AutoProxy.
:func:`email.utils.getaddresses` now accepts :class:`email.header.Header` objects along with string values. Patch by Zackery Spytz.
Add SQLite error code and name to :mod:`sqlite3` exceptions. Patch by Aviv Palivoda, Daniel Shahaf, and Erlend E. Aasland.
pty.spawn no longer hangs on FreeBSD, macOS, and Solaris.
lib2to3 now recognizes async generators everywhere.
Fix TypeError
when required subparsers without dest
do not receive
arguments. Patch by Anthony Sottile.
Remove extra documentation listing methods in difflib
. It was rendering
twice in pydoc and was outdated in some places.
:mod:`collections.abc` documentation has been expanded to explicitly cover how instance and subclass checks work, with additional doctest examples and an exhaustive list of ABCs which test membership purely by presence of the right :term:`special method`s. Patch by Raymond Hettinger.
Promote PEP 604 union syntax by using it where possible. Also, mention X |
Y
more prominently in section about Union
and mention X | None
at
all in section about Optional
.
Added code equivalents for the :meth:`int.to_bytes` and :meth:`int.from_bytes` methods, as well as tests ensuring that these code equivalents are valid.
Removed the othergui.rst
file, any references to it, and the list of GUI
frameworks in the FAQ. In their place I've added links to the Python Wiki
page on GUI frameworks.
Tkinter documentation has been greatly expanded with new "Architecture" and "Threading model" sections.
:mod:`base64` RFC references were updated to point to RFC 4648; a section was added to point users to the new "security considerations" section of the RFC.
Replaced occurrences of uppercase "Web" and "Internet" with lowercase versions per the 2016 revised Associated Press Style Book.
Update the definition of __future__ in the glossary by replacing the confusing word "pseudo-module" with a more accurate description.
Add typical examples to os.path.splitext docs
Clarify that :func:`shutil.make_archive` is not thread-safe due to reliance on changing the current working directory.
Update of three expired hyperlinks in Doc/distributing/index.rst: "Project structure", "Building and packaging the project", and "Uploading the project to the Python Packaging Index".
Delete entry "coercion" in Doc/glossary.rst for its outdated definition.
Updated the docstring and docs of :func:`filecmp.cmp` to be more accurate and less confusing especially in respect to shallow arg.
Refactored the repr()
code of the _Environ
(os module).
importlib.metadata is no longer provisional.
Match the docstring and python implementation of :func:`~operator.countOf` to the behavior of its c implementation.
List all kwargs for :func:`textwrap.wrap`, :func:`textwrap.fill`, and :func:`textwrap.shorten`. Now, there are nav links to attributes of :class:`TextWrap`, which makes navigation much easier while minimizing duplication in the documentation.
Clarify that atexit uses equality comparisons internally.
Convert examples in tutorial controlflow.rst section 4.3 to be interpreter-demo style.
Added a warning to :mod:`zipfile` docs: filename arg with a leading slash may cause archive to be un-openable on Windows systems.
Rewrote Doc/library/__main__.rst
. Broadened scope of the document to
explicitly discuss and differentiate between __main__.py
in packages
versus the __name__ == '__main__'
expression (and the idioms that
surround it).
In the Design FAQ, answer "Why don't generators support the with statement?"
Documentation of csv.Dialect is more descriptive.
Fix documentation for the return type of :func:`sysconfig.get_path`.
Added a new section in the C API documentation for types used in type
hinting. Documented Py_GenericAlias
and Py_GenericAliasType
.
Mark typing.io
and typing.re
as deprecated since Python 3.8 in the
documentation. They were never properly supported by type checkers.
Document that SyntaxError args have a details tuple and that details are adjusted for errors in f-string field replacement expressions.
Document the deprecation and removal of the loop
parameter for many
functions and classes in :mod:`asyncio`.
Corrected references to TraversableResources
in docs. There is no
TraversableReader
.
Document that ConfigParser
strips off comments when reading
configuration files.
Correct where in the numeric ABC hierarchy **
support is added, i.e., in
numbers.Complex, not numbers.Integral.
Add the remark to :mod:`dataclasses` documentation that the :meth:`__init__` of any base class has to be called in :meth:`__post_init__`, along with a code example.
Clarify when '_' in match statements is a keyword, and when not.
Fix docs about how methods like __add__
are invoked when evaluating
operator expressions.
Document that :class:`collections.defaultdict` parameter default_factory
defaults to None
and is positional-only.
document BaseException in favor of bare except
The description for __file__ fixed. Patch by Furkan Onder
Add a "Security Considerations" index which links to standard library modules that have explicitly documented security considerations.
Remove the unqualified claim that tkinter is threadsafe. It has not been true for several years and likely never was. An explanation of what is true may be added later, after more discussion, and possibly after patching _tkinter.c,
Fix :func:`test.support.import_helper.import_fresh_module`.
Add a test case for empty :class:`typing.NamedTuple`.
Cover case when invalid markers
type is supplied to c_make_encoder
.
Fix test_multiprocessing_fork
failure due to test_logging
and
sys.modules
manipulation.
Fix UserWarning: resource_tracker
warning in
_test_multiprocessing._TestSharedMemory.test_shared_memory_cleaned_after_process_termination
Enables TestEnumerations
test cases in test_ssl
suite.
Fix test_readline.test_nonascii(): sometimes, the newline character is not written at the end, so don't expect it in the output. Patch by Victor Stinner.
Fixes infinite loop on :func:`unittest.mock.seal` of mocks created by :func:`~unittest.create_autospec`.
Improves pickling tests and docs of SharedMemory
and SharableList
objects.
Update test_sysconfig.test_user_similar()
for the posix_user scheme:
platlib
doesn't use :data:`sys.platlibdir`. Patch by Victor Stinner.
WithProcessesTestSharedMemory.test_shared_memory_basics
test was
ignored, because self.assertEqual(sms.size, sms2.size)
line was failing.
It is now removed and test is unskipped.
The main motivation for this line to be removed from the test is that the
size
of SharedMemory
is not ever guaranteed to be the same. It is
decided by the platform.
libregrtest now clears the type cache later to reduce the risk of false alarm when checking for reference leaks. Previously, the type cache was cleared too early and libregrtest raised a false alarm about reference leaks under very specific conditions. Patch by Irit Katriel and Victor Stinner.
Fixes that test classes decorated with
@hashlib_helper.requires_hashdigest
were skipped all the time.
Add calls of :func:`gc.collect` in tests to support PyPy.
Made tests relying on the :mod:`!_asyncio` C extension module optional to allow running on alternative Python implementations. Patch by Serhiy Storchaka.
Fix auto history tests of test_readline: sometimes, the newline character is not written at the end, so don't expect it in the output.
Tests were added to clarify :func:`id` is preserved when obj * 1
is used
on :class:`str` and :class:`bytes` objects. Patch by Nikita Sobolev.
Add ability to wholesale silence DeprecationWarnings while running the regression test suite.
Notify users running test_decimal regression tests on macOS of potential harmless "malloc can't allocate region" messages spewed by test_decimal.
Fixed floating-point precision issue in turtle tests.
Regression tests, when run with -w, are now re-running only the affected test methods instead of re-running the entire test file.
Added interop tests for Apple plists: generate plist files with Python plistlib and parse with Apple plutil; and the other way round.
Added a permanent Unicode-valued environment variable to regression tests to ensure they handle this use case in the future. If your test environment breaks because of that, report a bug to us, and temporarily set PYTHONREGRTEST_UNICODE_GUARD=0 in your test environment.
Adjust recently added contextlib tests to avoid assuming the use of a refcounted GC
Fix asyncio test_popen() of test_windows_utils by using a longer timeout. Use military grade battle-tested :data:`test.support.SHORT_TIMEOUT` timeout rather than a hardcoded timeout of 10 seconds: it's 30 seconds by default, but it is made longer on slow buildbots. Patch by Victor Stinner.
Reset DeprecationWarning
filters in
test.test_importlib.test_metadata_api.APITests.test_entry_points_by_index
to avoid StopIteration
error if DeprecationWarnings
are ignored.
Account for address sanitizer in test_capi. test_capi now passes when run GCC address sanitizer.
Add non integral tests for :func:`math.sqrt` function.
Fix test_ssl.test_wrong_cert_tls13(): use suppress_ragged_eofs=False
,
since read()
can raise :exc:`ssl.SSLEOFError` on Windows. Patch by
Victor Stinner.
Fix test_pha_required_nocert() of test_ssl: catch two more EOF cases (when
the recv()
method returns an empty string). Patch by Victor Stinner.
Add test_frozenmain to test_embed to test the :c:func:`Py_FrozenMain` C function. Patch by Victor Stinner.
Ignore error string case in test_file_not_exists().
Add test to check that PyStructSequence_NewType
accepts a
PyStructSequence_Desc
with doc
field set to NULL
.
Fix crash in doctest when doctest parses modules that include unwrappable functions by skipping those functions.
Add test for nested queues when using multiprocessing
shared objects
AutoProxy[Queue]
inside ListProxy
and DictProxy
Avoid building with the Windows 11 SDK previews automatically. This may be
overridden by setting the DefaultWindowsSDKVersion
environment variable
before building.
Freeze stdlib modules that are imported during startup. This provides significant performance improvements to startup. If necessary, use the previously added "-X frozen_modules=off" commandline option to force importing the source modules.
Windows builds now regenerate frozen modules as the first part of the build. Previously the regeneration was later in the build, which would require it to be restarted if any modules had changed.
Fixes Haiku platform build.
The ncurses function extended_color_content was introduced in 2017
(https://invisible-island.net/ncurses/NEWS.html#index-t20170401). The
ncurses-devel package in CentOS 7 had a older version ncurses resulted in compilation error. For compiling ncurses with extended color support, we verify the version of the ncurses library >= 20170401.
Generate lines in relevant files for frozen modules. Up until now each of the files had to be edited manually. This change makes it easier to add to and modify the frozen modules.
Add support for building with clang thin lto via --with-lto=thin/full. Patch by Donghee Na and Brett Holman.
Enable building using a Visual Studio 2022 install on Windows.
Improved error message when building without a Windows SDK installed.
The Windows build now accepts :envvar:`EnableControlFlowGuard` set to
guard
to enable CFG.
Fix broken make install
that caused standard library extension modules
to be unnecessarily and incorrectly rebuilt during the install phase of
cpython.
Fixes an assertion failure due to searching for the standard library in unnormalised paths.
Update Windows release to include libffi 3.4.2
Update to OpenSSL 1.1.1l in Windows build
Upgrade Windows installer to use SQLite 3.36.0.
Avoid consuming standard input in the :mod:`platform` module
Accelerate speed of :mod:`mimetypes` initialization using a native implementation of the registry scan.
Fix 16 milliseconds jitter when using timeouts in :mod:`threading`, such as with :meth:`threading.Lock.acquire` or :meth:`threading.Condition.wait`.
Build :mod:`sqlite3` with math functions enabled. Patch by Erlend E. Aasland.
This is a follow-on bug from https://bugs.python.org/issue26903. Once that is applied we run into an off-by-one assertion problem. The assert was not correct.
Update macOS installer builds to use OpenSSL 1.1.1l.
When building CPython on macOS with ./configure
--with-undefined-behavior-sanitizer --with-pydebug
, the stack size is now
quadrupled to allow for the entire test suite to pass.
Update macOS installer to use SQLite 3.36.0.
:meth:`ctypes.util.find_library` now works correctly on macOS 11 Big Sur
even if Python is built on an older version of macOS. Previously, when
built on older macOS systems, find_library
was not able to find macOS
system libraries when running on Big Sur due to changes in how system
libraries are stored.
The framework build's user header path in sysconfig is changed to add a 'pythonX.Y' component to match distutils's behavior.
Allow --with-lto configure option to work with Apple-supplied Xcode or Command Line Tools.
Add socket.TCP_KEEPALIVE support for macOS. Patch by Shane Harvey.
On Windows, change exit/quit message to suggest Ctrl-D, which works, instead of <Ctrl-Z Return>, which does not work in IDLE.
Make completion boxes appear on Ubuntu again.
Mostly fix completions on macOS when not using tcl/tk 8.6.11 (as with 3.9). The added update_idletask call should be harmless and possibly helpful otherwise.
Move the indent space setting from the Font tab to the new Windows tab. Patch by Mark Roseman and Terry Jan Reedy.
Split the settings dialog General tab into Windows and Shell/ED tabs. Move help sources, which extend the Help menu, to the Extensions tab. Make space for new options and shorten the dialog. The latter makes the dialog better fit small screens.
Avoid uncaught exceptions in AutoCompleteWindow.winconfig_event()
.
Fix IDLE sometimes freezing upon tab-completion on macOS.
Highlight the new :ref:`match <match>` statement's :ref:`soft keywords
<soft-keywords>`: :keyword:`match`, :keyword:`case <match>`, and :keyword:`_
<wildcard-patterns>`. However, this highlighting is not perfect and will be
incorrect in some rare cases, including some _
-s in case
patterns.
Include interpreter's typo fix suggestions in message line for NameErrors and AttributeErrors. Patch by E. Paine.
Fix a warning in regular expression in the c-analyzer script.
pydoc now returns a non-zero status code when a module cannot be found.
Allow the Argument Clinic tool to handle __complex__
special methods.
Removed the 'test2to3' demo project that demonstrated using lib2to3 to support Python 2.x and Python 3.x from a single source in a distutils package. Patch by Donghee Na
Make patchcheck automatically detect the correct base branch name (previously it was hardcoded to 'master')
Added support for variadic positional parameters in Argument Clinic.
The PyThread_acquire_lock_timed() function now clamps the timeout if it is too large, rather than aborting the process. Patch by Victor Stinner.
:meth:`BufferedReader.peek` no longer raises :exc:`ValueError` when the entire file has already been buffered.
Add the :c:macro:`Py_ALWAYS_INLINE` macro to ask the compiler to always inline a static inline function. The compiler can ignore it and decides to not inline the function. Patch by Victor Stinner.
Add the :c:macro:`Py_NO_INLINE` macro to disable inlining on a function. Patch by Victor Stinner.
Add a deallocator to the :class:`bool` type to detect refcount bugs in C
extensions which call Py_DECREF(Py_True);
or Py_DECREF(Py_False);
by
mistake. Patch by Victor Stinner.
Add a new :c:func:`PyType_GetQualName` function to get type's qualified name.
Reverts removal of the old buffer protocol because they are part of stable ABI.
Remove crypt.h
include from the public Python.h
header.
The Py_TPFLAGS_HAVE_VERSION_TAG
type flag now does nothing. The
Py_TPFLAGS_HAVE_AM_SEND
flag (which was added in 3.10) is removed. Both
were unnecessary because it is not possible to have type objects with the
relevant fields missing.
Added the co_qualname
to the PyCodeObject
structure to propagate the
qualified name from the compiler to code objects.
Patch by Gabriele N. Tornetta
:c:func:`Py_RunMain` now resets :c:data:`PyImport_Inittab` to its initial value at exit. It must be possible to call :c:func:`PyImport_AppendInittab` or :c:func:`PyImport_ExtendInittab` at each Python initialization. Patch by Victor Stinner.
Remove 4 private trashcan C API functions which were only kept for the backward compatibility of the stable ABI with Python 3.8 and older, since the trashcan API was not usable with the limited C API on Python 3.8 and older. The trashcan API was excluded from the limited C API in Python 3.9.
Removed functions:
- _PyTrash_deposit_object()
- _PyTrash_destroy_chain()
- _PyTrash_thread_deposit_object()
- _PyTrash_thread_destroy_chain()
The trashcan C API was never usable with the limited C API, since old
trashcan macros accessed directly :c:type:`PyThreadState` members like
_tstate->trash_delete_nesting
, whereas the :c:type:`PyThreadState`
structure is opaque in the limited C API.
Exclude also the PyTrash_UNWIND_LEVEL
constant from the C API.
Patch by Victor Stinner.
Removed documentation for the removed PyParser_*
C API.
The list in :ref:`limited-api-list` now shows the public name
:c:struct:`PyFrameObject` rather than _frame
. The non-existing entry
_node
no longer appears in the list.
:c:func:`Py_IS_TYPE` no longer uses :c:func:`Py_TYPE` to avoid a compiler
warning: no longer cast const PyObject*
to PyObject*
. Patch by
Victor Stinner.
Convert the :c:func:`Py_TYPE` and :c:func:`Py_SIZE` macros to static inline functions. The :c:func:`Py_SET_TYPE` and :c:func:`Py_SET_SIZE` functions must now be used to set an object type and size. Patch by Victor Stinner.
The :c:func:`PyType_Ready` function now raises an error if a type is defined with the :c:macro:`Py_TPFLAGS_HAVE_GC` flag set but has no traverse function (:c:member:`PyTypeObject.tp_traverse`). Patch by Victor Stinner.
The undocumented function :c:func:`Py_FrozenMain` is removed from the Limited API.
Deprecate the following functions to configure the Python initialization:
- :c:func:`!PySys_AddWarnOptionUnicode`
- :c:func:`!PySys_AddWarnOption`
- :c:func:`!PySys_AddXOption`
- :c:func:`!PySys_HasWarnOptions`
- :c:func:`!Py_SetPath`
- :c:func:`!Py_SetProgramName`
- :c:func:`!Py_SetPythonHome`
- :c:func:`!Py_SetStandardStreamEncoding`
- :c:func:`!_Py_SetProgramFullPath`
Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization Configuration <init-config>` instead (PEP 587).
Remove PyErr_SetFromErrnoWithUnicodeFilename()
,
PyErr_SetFromWindowsErrWithUnicodeFilename()
, and
PyErr_SetExcFromWindowsErrWithUnicodeFilename()
. They are not documented
and have been deprecated since Python 3.3.
:c:func:`PyCodec_Unregister` is now properly exported as a function in the Windows Stable ABI DLL.
Remove deprecated Py_UNICODE
APIs: PyUnicode_Encode
,
PyUnicode_EncodeUTF7
, PyUnicode_EncodeUTF8
,
PyUnicode_EncodeUTF16
, PyUnicode_EncodeUTF32
,
PyUnicode_EncodeLatin1
, PyUnicode_EncodeMBCS
,
PyUnicode_EncodeDecimal
, PyUnicode_EncodeRawUnicodeEscape
,
PyUnicode_EncodeCharmap
, PyUnicode_EncodeUnicodeEscape
,
PyUnicode_TransformDecimalToASCII
, PyUnicode_TranslateCharmap
,
PyUnicodeEncodeError_Create
, PyUnicodeTranslateError_Create
. See
PEP 393 and PEP 624 for reference.
Add a new :c:func:`PyType_GetName` function to get type's short name.