Changelog

Python 3.10.0 final

Release date: 2021-10-04

Core and Builtins

  • bpo-45121: Fix issue where Protocol.__init__ raises RecursionError when it’s called directly or via super(). Patch provided by Yurii Karabas.

Library

Documentation

  • bpo-45216: Remove extra documentation listing methods in difflib. It was rendering twice in pydoc and was outdated in some places.

  • bpo-45024: 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 special methods. Patch by Raymond Hettinger.

Tests

  • bpo-45128: Fix test_multiprocessing_fork failure due to test_logging and sys.modules manipulation.

  • bpo-44860: Update test_sysconfig.test_user_similar() for the posix_user scheme: platlib doesn’t use sys.platlibdir. Patch by Victor Stinner.

Build

IDLE

  • bpo-45193: Make completion boxes appear on Ubuntu again.

C API

  • bpo-45307: Restore the private C API function _PyImport_FindExtensionObject(). It will be removed in Python 3.11.

Python 3.10.0 release candidate 2

Release date: 2021-09-07

Security

  • bpo-42278: Replaced usage of tempfile.mktemp() with TemporaryDirectory to avoid a potential race condition.

  • bpo-44394: 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.

  • bpo-43124: Made the internal putcmd function in smtplib sanitize input for presence of \r and \n characters to avoid (unlikely) command injection.

Core and Builtins

  • bpo-45123: Fix PyAiter_Check to only check for the __anext__ presence (not for __aiter__). Rename PyAiter_Check to PyAIter_Check, PyObject_GetAiter -> PyObject_GetAIter.

  • bpo-45018: Fixed pickling of range iterators that iterated for over 2**32 times.

  • bpo-45000: A SyntaxError is now raised when trying to delete __debug__. Patch by Dong-hee Na.

  • bpo-44963: Implement send() and throw() methods for anext_awaitable objects. Patch by Pablo Galindo.

  • bpo-44962: 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

  • bpo-44954: Fixed a corner case bug where the result of float.fromhex('0x.8p-1074') was rounded the wrong way.

  • bpo-44947: Refine the syntax error for trailing commas in import statements. Patch by Pablo Galindo.

  • bpo-44698: Restore behaviour of complex exponentiation with integer-valued exponent of type float or complex.

  • bpo-44885: Correct the ast locations of f-strings with format specs and repeated expressions. Patch by Pablo Galindo

  • bpo-44872: Use new trashcan macros (Py_TRASHCAN_BEGIN/END) in frameobject.c instead of the old ones (Py_TRASHCAN_SAFE_BEGIN/END).

  • bpo-33930: Fix segmentation fault with deep recursion when cleaning method objects. Patch by Augusto Goulart and Pablo Galindo.

  • bpo-25782: Fix bug where PyErr_SetObject hangs when the current exception has a cycle in its context chain.

  • bpo-44856: Fix reference leaks in the error paths of update_bases() and __build_class__. Patch by Pablo Galindo.

  • bpo-44838: Fixed a bug that was causing the parser to raise an incorrect custom SyntaxError for invalid ‘if’ expressions. Patch by Pablo Galindo.

  • bpo-44584: The threading debug (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.

  • bpo-39091: Fix crash when using passing a non-exception to a generator’s throw() method. Patch by Noah Oxer

Library

  • bpo-45081: Fix issue when dataclasses that inherit from typing.Protocol subclasses have wrong __init__. Patch provided by Yurii Karabas.

  • bpo-41620: run() now always return a TestResult instance. Previously it returned None if the test class or method was decorated with a skipping decorator.

  • bpo-43913: Fix bugs in cleaning up classes and modules in unittest:

    • Functions registered with addModuleCleanup() were not called unless the user defines tearDownModule() in their test module.

    • Functions registered with addClassCleanup() were not called if tearDownClass is set to None.

    • Buffering in TestResult did not work with functions registered with addClassCleanup() and addModuleCleanup().

    • Errors in functions registered with addClassCleanup() and addModuleCleanup() were not handled correctly in buffered and debug modes.

    • Errors in setUpModule() and functions registered with addModuleCleanup() were reported in wrong order.

    • And several lesser bugs.

  • bpo-45030: Fix integer overflow in pickling and copying the range iterator.

  • bpo-45001: Made email date parsing more robust against malformed input, namely a whitespace-only Date: header. Patch by Wouter Bolsterlee.

  • bpo-44449: Fix a crash in the signal handler of the faulthandler module: no longer modify the reference count of frame objects. Patch by Victor Stinner.

  • bpo-44955: Method stopTestRun() is now always called in pair with method startTestRun() for TestResult objects implicitly created in run(). Previously it was not called for test methods and classes decorated with a skipping decorator.

  • bpo-44935: subprocess on Solaris now also uses os.posix_spawn() for better performance.

  • bpo-44911: IsolatedAsyncioTestCase will no longer throw an exception while cancelling leaked tasks. Patch by Bar Harel.

  • bpo-44524: Make exception message more useful when subclass from typing special form alias. Patch provided by Yurii Karabas.

  • bpo-38956: argparse.BooleanOptionalAction’s default value is no longer printed twice when used with argparse.ArgumentDefaultsHelpFormatter.

  • bpo-44860: Fix the posix_user scheme in sysconfig to not depend on sys.platlibdir.

  • bpo-44581: Upgrade bundled pip to 21.2.3 and setuptools to 57.4.0

  • bpo-44849: Fix the os.set_inheritable() function on FreeBSD 14 for file descriptor opened with the O_PATH flag: ignore the EBADF error on ioctl(), fallback on the fcntl() implementation. Patch by Victor Stinner.

  • bpo-44605: The @functools.total_ordering() decorator now works with metaclasses.

  • bpo-44524: Fixed an issue wherein the __name__ and __qualname__ attributes of subscribed specialforms could be None.

  • bpo-44822: sqlite3 user-defined functions and aggregators returning strings with embedded NUL characters are no longer truncated. Patch by Erlend E. Aasland.

  • bpo-44801: Ensure that the ParamSpec variable in Callable can only be substituted with a parameters expression (a list of types, an ellipsis, ParamSpec or Concatenate).

  • bpo-27334: The sqlite3 context manager now performs a rollback (thus releasing the database lock) if commit failed. Patch by Luca Citi and Erlend E. Aasland.

  • bpo-41402: Fix email.message.EmailMessage.set_content() when called with binary data and 7bit content transfer encoding.

  • bpo-32695: The compresslevel and preset keyword arguments of tarfile.open() are now both documented and tested.

  • bpo-34990: Fixed a Y2k38 bug in the compileall module where it would fail to compile files with a modification time after the year 2038.

  • bpo-38840: Fix test___all__ on platforms lacking a shared memory implementation.

  • bpo-26228: pty.spawn no longer hangs on FreeBSD, macOS, and Solaris.

  • bpo-33349: lib2to3 now recognizes async generators everywhere.

Documentation

  • bpo-44957: 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.

  • bpo-44903: 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.

  • bpo-33479: Tkinter documentation has been greatly expanded with new “Architecture” and “Threading model” sections.

  • bpo-36700: 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.

  • bpo-44756: Reverted automated virtual environment creation on make html when building documentation. It turned out to be disruptive for downstream distributors.

  • bpo-42958: Updated the docstring and docs of filecmp.cmp() to be more accurate and less confusing especially in respect to shallow arg.

  • bpo-43066: Added a warning to zipfile docs: filename arg with a leading slash may cause archive to be un-openable on Windows systems.

  • bpo-39452: 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).

  • bpo-27752: Documentation of csv.Dialect is more descriptive.

  • bpo-41576: document BaseException in favor of bare except

  • bpo-39498: Add a “Security Considerations” index which links to standard library modules that have explicitly documented security considerations.

  • bpo-33479: 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,

Tests

  • bpo-45052: 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.

  • bpo-45042: Fixes that test classes decorated with @hashlib_helper.requires_hashdigest were skipped all the time.

  • bpo-45011: Made tests relying on the _asyncio C extension module optional to allow running on alternative Python implementations. Patch by Serhiy Storchaka.

  • bpo-44949: 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.

  • bpo-44891: Tests were added to clarify id() is preserved when obj * 1 is used on str and bytes objects. Patch by Nikita Sobolev.

  • bpo-44852: Add ability to wholesale silence DeprecationWarnings while running the regression test suite.

  • bpo-40928: Notify users running test_decimal regression tests on macOS of potential harmless “malloc can’t allocate region” messages spewed by test_decimal.

Windows

  • bpo-45007: Update to OpenSSL 1.1.1l in Windows build

macOS

  • bpo-45007: Update macOS installer builds to use OpenSSL 1.1.1l.

  • bpo-44689: 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.

Python 3.10.0 release candidate 1

Release date: 2021-08-02

Security

  • bpo-44600: Fix incorrect line numbers while tracing some failed patterns in match statements. Patch by Charles Burkland.

Core and Builtins

  • bpo-44792: Improve syntax errors for if expressions. Patch by Miguel Brito

  • bpo-34013: 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

  • bpo-44732: Rename types.Union to types.UnionType.

  • bpo-44698: Fix undefined behaviour in complex object exponentiation.

  • bpo-44653: Support typing types in parameter substitution in the union type.

  • bpo-44676: Add ability to serialise types.Union objects. Patch provided by Yurii Karabas.

  • bpo-44633: Parameter substitution of the union type with wrong types now raises TypeError instead of returning NotImplemented.

  • bpo-44662: Add __module__ to types.Union. This also fixes types.Union issues with typing.Annotated. Patch provided by Yurii Karabas.

  • bpo-44655: Include the name of the type in unset __slots__ attribute errors. Patch by Pablo Galindo

  • bpo-44655: Don’t include a missing attribute with the same name as the failing one when offering suggestions for missing attributes. Patch by Pablo Galindo

  • bpo-44646: Fix the hash of the union type: it no longer depends on the order of arguments.

  • bpo-44636: 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.

  • bpo-44635: Convert None to type(None) in the union type constructor.

  • bpo-44589: Mapping patterns in match statements with two or more equal literal keys will now raise a SyntaxError at compile-time.

  • bpo-44606: Fix __instancecheck__ and __subclasscheck__ for the union type.

  • bpo-42073: The @classmethod decorator can now wrap other classmethod-like descriptors.

  • bpo-44490: 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.

  • bpo-44490: Add __parameters__ attribute and __getitem__ operator to types.Union. Patch provided by Yurii Karabas.

  • bpo-44472: Fix ltrace functionality when exceptions are raised. Patch by Pablo Galindo

Library

  • bpo-44806: Non-protocol subclasses of typing.Protocol ignore now the __init__ method inherited from protocol base classes.

  • bpo-44793: Fix checking the number of arguments when subscribe a generic type with ParamSpec parameter.

  • bpo-44784: In importlib.metadata tests, override warnings behavior under expected DeprecationWarnings (importlib_metadata 4.6.3).

  • bpo-44667: The 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

  • bpo-44752: rcompleter does not call getattr() on property objects to avoid the side-effect of evaluating the corresponding method.

  • bpo-44720: weakref.proxy objects referencing non-iterators now raise TypeError rather than dereferencing the null tp_iternext slot and crashing.

  • bpo-44704: The implementation of collections.abc.Set._hash() now matches that of frozenset.__hash__().

  • bpo-44666: Fixed issue in compileall.compile_file() when sys.stdout is redirected. Patch by Stefan Hölzl.

  • bpo-42854: Fixed a bug in the _ssl module that was throwing OverflowError when using _ssl._SSLSocket.write() and _ssl._SSLSocket.read() for a big value of the len parameter. Patch by Pablo Galindo

  • bpo-44353: Refactor typing.NewType from function into callable class. Patch provided by Yurii Karabas.

  • bpo-44524: Add missing __name__ and __qualname__ attributes to typing module classes. Patch provided by Yurii Karabas.

  • bpo-40897: Give priority to using the current class constructor in inspect.signature(). Patch by Weipeng Hong.

  • bpo-44648: Fixed wrong error being thrown by inspect.getsource() when examining a class in the interactive session. Instead of TypeError, it should be OSError with appropriate error message.

  • bpo-44608: Fix memory leak in _tkinter._flatten() if it is called with a sequence or set, but not list or tuple.

  • bpo-44559: [Enum] module reverted to 3.9; 3.10 changes pushed until 3.11

  • bpo-41928: Update shutil.copyfile() to raise FileNotFoundError instead of confusing IsADirectoryError when a path ending with a os.path.sep does not exist; shutil.copy() and shutil.copy2() are also affected.

  • bpo-44566: handle StopIteration subclass raised from @contextlib.contextmanager generator

  • bpo-41249: Fixes TypedDict to work with typing.get_type_hints() and postponed evaluation of annotations across modules.

  • bpo-44461: Fix bug with pdb’s handling of import error due to a package which does not have a __main__ module

  • bpo-43625: Fix a bug in the detection of CSV file headers by csv.Sniffer.has_header() and improve documentation of same.

  • bpo-42892: Fixed an exception thrown while parsing a malformed multipart email by email.message.EmailMessage.

  • bpo-27827: pathlib.PureWindowsPath.is_reserved() now identifies a greater range of reserved filenames, including those with trailing spaces or colons.

  • bpo-38741: configparser: using ‘]’ inside a section header will no longer cut the section name short at the ‘]’

  • bpo-27513: email.utils.getaddresses() now accepts email.header.Header objects along with string values. Patch by Zackery Spytz.

  • bpo-29298: Fix TypeError when required subparsers without dest do not receive arguments. Patch by Anthony Sottile.

Documentation

  • bpo-44740: Replaced occurences of uppercase “Web” and “Internet” with lowercase versions per the 2016 revised Associated Press Style Book.

  • bpo-44693: Update the definition of __future__ in the glossary by replacing the confusing word “pseudo-module” with a more accurate description.

  • bpo-35183: Add typical examples to os.path.splitext docs

  • bpo-30511: Clarify that shutil.make_archive() is not thread-safe due to reliance on changing the current working directory.

  • bpo-44561: 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”.

  • bpo-44613: importlib.metadata is no longer provisional.

  • bpo-44544: List all kwargs for textwrap.wrap(), textwrap.fill(), and textwrap.shorten(). Now, there are nav links to attributes of TextWrap, which makes navigation much easier while minimizing duplication in the documentation.

  • bpo-44453: Fix documentation for the return type of sysconfig.get_path().

Tests

  • bpo-44734: Fixed floating point precision issue in turtle tests.

  • bpo-44708: Regression tests, when run with -w, are now re-running only the affected test methods instead of re-running the entire test file.

  • bpo-44647: 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.

  • bpo-44515: Adjust recently added contextlib tests to avoid assuming the use of a refcounted GC

Windows

macOS

  • bpo-41972: The framework build’s user header path in sysconfig is changed to add a ‘pythonX.Y’ component to match distutils’s behavior.

  • bpo-34932: Add socket.TCP_KEEPALIVE support for macOS. Patch by Shane Harvey.

Tools/Demos

  • bpo-44756: In the Makefile for documentation (Doc/Makefile), the build rule is dependent on the venv rule. Therefore, html, latex, and other build-dependent rules are also now dependent on venv. The venv rule only performs an action if $(VENVDIR) does not exist. Doc/README.rst was updated; most users now only need to type make html.

C API

  • bpo-41103: Reverts removal of the old buffer protocol because they are part of stable ABI.

  • bpo-42747: 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.

Python 3.10.0 beta 4

Release date: 2021-07-10

Security

  • bpo-41180: Add auditing events to the 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.

Core and Builtins

  • bpo-44562: Remove uses of PyObject_GC_Del() in error path when initializing types.GenericAlias.

  • bpo-41486: 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.

  • bpo-44553: Implement GC methods for types.Union to break reference cycles and prevent memory leaks.

  • bpo-44523: Remove the pass-through for hash() of 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.

  • bpo-44483: Fix a crash in types.Union objects when creating a union of an object with bad __module__ field.

  • bpo-44297: Make sure that the line number is set when entering a comprehension scope. Ensures that backtraces inclusing generator expressions show the correct line number.

  • bpo-44456: Improve the syntax error when mixing positional and keyword patterns. Patch by Pablo Galindo.

  • bpo-44368: Improve syntax errors for invalid “as” targets. Patch by Pablo Galindo

  • bpo-44317: Improve tokenizer error with improved locations. Patch by Pablo Galindo.

  • bpo-43667: Improve Unicode support in non-UTF locales on Oracle Solaris. This issue does not affect other Solaris systems.

Library

  • bpo-44558: Make the implementation consistency of indexOf() between C and Python versions. Patch by Dong-hee Na.

  • bpo-34798: Break up paragraph about pprint.PrettyPrinter construction parameters to make it easier to read.

  • bpo-44516: Update vendored pip to 21.1.3

  • bpo-44468: typing.get_type_hints() now finds annotations in classes and base classes with unexpected __module__. Previously, it skipped those MRO elements.

  • bpo-43977: Set the proper Py_TPFLAGS_MAPPING and Py_TPFLAGS_SEQUENCE flags for subclasses created before a parent has been registered as a collections.abc.Mapping or collections.abc.Sequence.

  • bpo-44482: Fix very unlikely resource leak in glob in alternate Python implementations.

  • bpo-44466: The faulthandler module now detects if a fatal error occurs during a garbage collector collection. Patch by Victor Stinner.

  • bpo-44404: tkinter’s after() method now supports callables without the __name__ attribute.

  • bpo-44458: BUFFER_BLOCK_SIZE is now declared static, to avoid linking collisions when bz2, lmza or zlib are statically linked.

  • bpo-44464: Remove exception for flake8 in deprecated importlib.metadata interfaces. Sync with importlib_metadata 4.6.

  • bpo-44446: Take into account that lineno might be None in traceback.FrameSummary.

  • bpo-44439: Fix in bz2.BZ2File.write() / lzma.LZMAFile.write() methods, when the input data is an object that supports the buffer protocol, the file length may be wrong.

  • bpo-44434: _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.

  • bpo-44395: Fix as_string() to pass unixfrom properly. Patch by Dong-hee Na.

  • bpo-34266: Handle exceptions from parsing the arg of pdb’s run/restart command.

  • bpo-44077: It’s now possible to receive the type of service (ToS), a.k.a. differentiated services (DS), a.k.a. differenciated services code point (DSCP) and excplicit congestion notification (ECN) IP header fields with socket.IP_RECVTOS.

  • bpo-43024: Improve the help signature of traceback.print_exception(), traceback.format_exception() and traceback.format_exception_only().

  • bpo-30256: Pass multiprocessing BaseProxy argument manager_owned through AutoProxy.

Documentation

  • bpo-44558: Match the docstring and python implementation of countOf() to the behavior of its c implementation.

  • bpo-38062: Clarify that atexit uses equality comparisons internally.

  • bpo-40620: Convert examples in tutorial controlflow.rst section 4.3 to be interpreter-demo style.

  • bpo-13814: In the Design FAQ, answer “Why don’t generators support the with statement?”

  • bpo-41621: Document that collections.defaultdict parameter default_factory defaults to None and is positional-only.

Tests

  • bpo-44287: Fix asyncio test_popen() of test_windows_utils by using a longer timeout. Use military grade battle-tested 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.

  • bpo-44451: Reset DeprecationWarning filters in test.test_importlib.test_metadata_api.APITests.test_entry_points_by_index to avoid StopIteration error if DeprecationWarnings are ignored.

  • bpo-30256: Add test for nested queues when using multiprocessing shared objects AutoProxy[Queue] inside ListProxy and DictProxy

Build

  • bpo-44535: Enable building using a Visual Studio 2022 install on Windows.

  • bpo-43298: Improved error message when building without a Windows SDK installed.

Windows

C API

Python 3.10.0 beta 3

Release date: 2021-06-17

Core and Builtins

  • bpo-44409: Fix error location information for tokenizer errors raised on initialization of the tokenizer. Patch by Pablo Galindo.

  • bpo-44396: Fix a possible crash in the tokenizer when raising syntax errors for unclosed strings. Patch by Pablo Galindo.

  • bpo-44349: Fix an edge case when displaying text from files with encoding in syntax errors. Patch by Pablo Galindo.

  • bpo-44335: Fix a regression when identifying incorrect characters in syntax errors. Patch by Pablo Galindo

  • bpo-44304: Fix a crash in the sqlite3 module that happened when the garbage collector clears sqlite.Statement objects. Patch by Pablo Galindo

  • bpo-44305: Improve error message for try blocks without except or finally blocks. Patch by Pablo Galindo.

  • bpo-43833: 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.

  • bpo-11105: When compiling ast.AST objects with recursive references through compile(), the interpreter doesn’t crash anymore instead it raises a RecursionError.

Library

  • bpo-42972: The _thread.RLock type now fully implement the GC protocol: add a traverse function and the Py_TPFLAGS_HAVE_GC flag. Patch by Victor Stinner.

  • bpo-44422: The threading.enumerate() function now uses a reentrant lock to prevent a hang on reentrant call. Patch by Victor Stinner.

  • bpo-44389: Fix deprecation of ssl.OP_NO_TLSv1_3

  • bpo-44362: Improve ssl module’s deprecation messages, error reporting, and documentation for deprecations.

  • bpo-44342: [Enum] Change pickling from by-value to by-name.

  • bpo-44356: [Enum] Allow multiple data-type mixins if they are all the same.

  • bpo-44351: Restore back parse_makefile() in distutils.sysconfig because it behaves differently than the similar implementation in sysconfig.

  • bpo-44242: Remove missing flag check from Enum creation and move into a verify decorator.

  • bpo-44246: 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]).

  • bpo-44246: 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.

  • bpo-43853: Improved string handling for sqlite3 user-defined functions and aggregates:

    • It is now possible to pass strings with embedded null characters to UDFs

    • Conversion failures now correctly raise MemoryError

    Patch by Erlend E. Aasland.

  • bpo-43318: Fix a bug where pdb does not always echo cleared breakpoints.

  • bpo-37022: pdb now displays exceptions from repr() with its p and pp commands.

Documentation

  • bpo-44392: Added a new section in the C API documentation for types used in type hinting. Documented Py_GenericAlias and Py_GenericAliasType.

  • bpo-38291: Mark typing.io and typing.re as deprecated since Python 3.8 in the documentation. They were never properly supported by type checkers.

  • bpo-44322: Document that SyntaxError args have a details tuple and that details are adjusted for errors in f-string field replacement expressions.

Tests

  • bpo-44363: Account for address sanitizer in test_capi. test_capi now passes when run GCC address sanitizer.

  • bpo-43921: Fix test_ssl.test_wrong_cert_tls13(): use suppress_ragged_eofs=False, since read() can raise ssl.SSLEOFError on Windows. Patch by Victor Stinner.

  • bpo-43921: 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.

Build

  • bpo-44381: The Windows build now accepts EnableControlFlowGuard set to guard to enable CFG.

IDLE

  • bpo-40128: 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.

  • bpo-33962: Move the indent space setting from the Font tab to the new Windows tab. Patch by Mark Roseman and Terry Jan Reedy.

  • bpo-40468: 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.

C API

Python 3.10.0 beta 2

Release date: 2021-05-31

Security

  • bpo-44022: mod:http.client now avoids infinitely reading potential HTTP headers after a 100 Continue status response from the server.

Core and Builtins

  • bpo-43667: Improve Unicode support in non-UTF locales on Oracle Solaris. This issue does not affect other Solaris systems.

  • bpo-44232: Fix a regression in type() when a metaclass raises an exception. The C function 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.

  • bpo-44201: 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

  • bpo-44184: Fix a crash at Python exit when a deallocator function removes the last strong reference to a heap type. Patch by Victor Stinner.

  • bpo-44180: 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

  • bpo-44168: Fix error message in the parser involving keyword arguments with invalid expressions. Patch by Pablo Galindo

  • bpo-44143: Fixed a crash in the parser that manifest when raising tokenizer errors when an existing exception was present. Patch by Pablo Galindo.

  • bpo-44114: Fix incorrect dictkeys_reversed and dictitems_reversed function signatures in C code, which broke webassembly builds.

  • bpo-43149: Corrent the syntax error message regarding multiple exception types to not refer to “exception groups”. Patch by Pablo Galindo

  • bpo-44056: Syntax errors when default except is not the last except are reported with the correct location. Patch by Mark Shannon.

  • bpo-43822: The parser will prioritize tokenizer errors over custom syntax errors when raising exceptions. Patch by Pablo Galindo.

  • bpo-28146: Fix a confusing error message in str.format().

Library

  • bpo-44254: On Mac, give turtledemo button text a color that works on both light or dark background. Programmers cannot control the latter.

  • bpo-38693: Prefer f-strings to .format in importlib.resources.

  • bpo-33693: Importlib.metadata now prefers f-strings to .format.

  • bpo-44241: Incorporate minor tweaks from importlib_metadata 4.1: SimplePath protocol, support for Metadata 2.2.

  • bpo-44210: Make importlib.metadata._meta.PackageMetadata public.

  • bpo-43643: Declare readers.MultiplexedPath.name as a property per the spec.

  • bpo-33433: For IPv4 mapped IPv6 addresses (RFC 4291 Section 2.5.5.2), the 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.

  • bpo-44145: 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 hashlib algorithms support.

  • bpo-37788: Fix a reference leak when a Thread object is never joined.

  • bpo-38908: Subclasses of typing.Protocol which only have data variables declared will now raise a TypeError when checked with isinstance unless they are decorated with runtime_checkable(). Previously, these checks passed silently. Patch provided by Yurii Karabas.

  • bpo-44098: typing.ParamSpec will no longer be found in the __parameters__ of most 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.

  • bpo-44089: Allow subclassing csv.Error in 3.10 (it was allowed in 3.9 and earlier but was disallowed in early versions of 3.10).

  • bpo-44059: Register the SerenityOS Browser in the webbrowser module.

  • bpo-36515: The hashlib module no longer does unaligned memory accesses when compiled for ARM platforms.

  • bpo-44018: random.seed() no longer mutates bytearray inputs.

  • bpo-38352: Add IO, BinaryIO, TextIO, Match, and Pattern to typing.__all__. Patch by Jelle Zijlstra.

  • bpo-43972: When 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.

  • bpo-28528: Fix a bug in pdb where checkline() raises AttributeError if it is called after reset().

  • bpo-43650: Fix MemoryError in shutil.unpack_archive() which fails inside shutil._unpack_zipfile() on large files. Patch by Igor Bolshakov.

  • bpo-41730: DeprecationWarning is now raised when importing tkinter.tix, which has been deprecated in documentation since Python 3.6.

Documentation

  • bpo-42392: Document the deprecation and removal of the loop parameter for many functions and classes in asyncio.

  • bpo-44195: Corrected references to TraversableResources in docs. There is no TraversableReader.

  • bpo-41963: Document that ConfigParser strips off comments when reading configuration files.

  • bpo-44072: Correct where in the numeric ABC hierarchy ** support is added, i.e., in numbers.Complex, not numbers.Integral.

  • bpo-43558: Add the remark to dataclasses documentation that the __init__() of any base class has to be called in __post_init__(), along with a code example.

  • bpo-44025: Clarify when ‘_’ in match statements is a keyword, and when not.

Tests

  • bpo-31904: Ignore error string case in test_py_compile test_file_not_exists().

  • bpo-42083: Add test to check that PyStructSequence_NewType accepts a PyStructSequence_Desc with doc field set to NULL.

  • bpo-35753: Fix crash in doctest when doctest parses modules that include unwrappable functions by skipping those functions.

Build

  • bpo-41282: Fix broken make install that caused standard library extension modules to be unnecessarily and incorrectly rebuilt during the install phase of cpython.

Windows

  • bpo-42686: Build sqlite3 with math functions enabled. Patch by Erlend E. Aasland.

macOS

  • bpo-43109: Allow –with-lto configure option to work with Apple-supplied Xcode or Command Line Tools.

IDLE

  • bpo-41611: Avoid uncaught exceptions in AutoCompleteWindow.winconfig_event().

  • bpo-41611: Fix IDLE sometimes freezing upon tab-completion on macOS.

  • bpo-44010: Highlight the new match statement’s soft keywords: match, case, and _. However, this highlighting is not perfect and will be incorrect in some rare cases, including some _-s in case patterns.

  • bpo-44026: Include interpreter’s typo fix suggestions in message line for NameErrors and AttributeErrors. Patch by E. Paine.

Tools/Demos

  • bpo-44074: Make patchcheck automatically detect the correct base branch name (previously it was hardcoded to ‘master’)

C API

Python 3.10.0 beta 1

Release date: 2021-05-03

Security

  • bpo-43434: Creating sqlite3.Connection objects now also produces sqlite3.connect and sqlite3.connect/handle auditing events. Previously these events were only produced by sqlite3.connect() calls. Patch by Erlend E. Aasland.

  • bpo-43998: The ssl module sets more secure cipher suites defaults. Ciphers without forward secrecy and with SHA-1 MAC are disabled by default. Security level 2 prohibits weak RSA, DH, and ECC keys with less than 112 bits of security. SSLContext defaults to minimum protocol version TLS 1.2. Settings are based on Hynek Schlawack’s research.

  • bpo-43882: The presence of newline or tab characters in parts of a URL could allow some forms of attacks.

    Following the controlling specification for URLs defined by WHATWG urllib.parse() now removes ASCII newlines and tabs from URLs, preventing such attacks.

  • bpo-43472: Ensures interpreter-level audit hooks receive the cpython.PyInterpreterState_New event when called through the _xxsubinterpreters module.

  • bpo-43362: Fix invalid free in _sha3 module. The issue was introduced in 3.10.0a1. Python 3.9 and earlier are not affected.

  • bpo-43762: Add audit events for sqlite3.connect/handle(), sqlite3.Connection.enable_load_extension(), and sqlite3.Connection.load_extension(). Patch by Erlend E. Aasland.

  • bpo-43756: Add new audit event glob.glob/2 to incorporate the new root_dir and dir_fd arguments added to glob.glob() and glob.iglob().

  • bpo-36384: ipaddress module no longer accepts any leading zeros in IPv4 address strings. Leading zeros are ambiguous and interpreted as octal notation by some libraries. For example the legacy function socket.inet_aton() treats leading zeros as octal notatation. glibc implementation of modern inet_pton() does not accept any leading zeros. For a while the ipaddress module used to accept ambiguous leading zeros.

  • bpo-43075: Fix Regular Expression Denial of Service (ReDoS) vulnerability in urllib.request.AbstractBasicAuthHandler. The ReDoS-vulnerable regex has quadratic worst-case complexity and it allows cause a denial of service when identifying crafted invalid RFCs. This ReDoS issue is on the client side and needs remote attackers to control the HTTP server.

  • bpo-42800: Audit hooks are now fired for frame.f_code, traceback.tb_frame, and generator code/frame attribute access.

  • bpo-37363: Add audit events to the http.client module.

Core and Builtins

  • bpo-43977: Prevent classes being both a sequence and a mapping when pattern matching.

  • bpo-43977: Use tp_flags on the class object to determine if the subject is a sequence or mapping when pattern matching. Avoids the need to import collections.abc when pattern matching.

  • bpo-43892: Restore proper validation of complex literal value patterns when parsing match blocks.

  • bpo-43933: Set frame.f_lineno to the line number of the ‘with’ kweyword when executing the call to __exit__.

  • bpo-43933: If the current position in a frame has no line number then set the f_lineno attribute to None, instead of -1, to conform to PEP 626. This should not normally be possible, but might occur in some unusual circumstances.

  • bpo-43963: Importing the _signal module in a subinterpreter has no longer side effects.

  • bpo-42739: The internal representation of line number tables is changed to not use sentinels, and an explicit length parameter is added to the out of process API function PyLineTable_InitAddressRange. This makes the handling of line number tables more robust in some circumstances.

  • bpo-43908: Make re types immutable. Patch by Erlend E. Aasland.

  • bpo-43908: Make the array.array type immutable. Patch by Erlend E. Aasland.

  • bpo-43901: Change class and module objects to lazy-create empty annotations dicts on demand. The annotations dicts are stored in the object’s __dict__ for backwards compatibility.

  • bpo-43892: Match patterns now use new dedicated AST nodes (MatchValue, MatchSingleton, MatchSequence, MatchStar, MatchMapping, MatchClass) rather than reusing expression AST nodes. MatchAs and MatchOr are now defined as pattern nodes rather than as expression nodes. Patch by Nick Coghlan.

  • bpo-42725: Usage of await/yield/yield from and named expressions within an annotation is now forbidden when PEP 563 is activated.

  • bpo-43754: When performing structural pattern matching (PEP 634), captured names are now left unbound until the entire pattern has matched successfully.

  • bpo-42737: Annotations for complex targets (everything beside simple names) no longer cause any runtime effects with from __future__ import annotations.

  • bpo-43914: SyntaxError exceptions raised by the intepreter will highlight the full error range of the expression that consistutes the syntax error itself, instead of just where the problem is detected. Patch by Pablo Galindo.

  • bpo-38605: Revert making from __future__ import annotations the default. This follows the Steering Council decision to postpone PEP 563 changes to at least Python 3.11. See the original email for more information regarding the decision: https://mail.python.org/archives/list/python-dev@python.org/thread/CLVXXPQ2T2LQ5MP2Y53VVQFCXYWQJHKZ/. Patch by Pablo Galindo.

  • bpo-43475: Hashes of NaN values now depend on object identity. Formerly, they always hashed to 0 even though NaN values are not equal to one another. Having the same hash for unequal values caused pile-ups in hash tables.

  • bpo-43859: Improve the error message for IndentationError exceptions. Patch by Pablo Galindo

  • bpo-41323: Constant tuple folding in bytecode optimizer now reuses tuple in constant table.

  • bpo-43846: Data stack usage is much reduced for large literal and call expressions.

  • bpo-38530: When printing NameError raised by the interpreter, PyErr_Display() will offer suggestions of similar variable names in the function that the exception was raised from. Patch by Pablo Galindo

  • bpo-43823: Improve syntax errors for invalid dictionary literals. Patch by Pablo Galindo.

  • bpo-43822: Improve syntax errors in the parser for missing commas between expressions. Patch by Pablo Galindo.

  • bpo-43798: ast.alias nodes now include source location metadata attributes e.g. lineno, col_offset.

  • bpo-43797: Improve SyntaxError error messages for invalid comparisons. Patch by Pablo Galindo.

  • bpo-43760: Move the flag for checking whether tracing is enabled to the C stack, from the heap. Should speed up dispatch in the interpreter.

  • bpo-43682: Static methods (@staticmethod) and class methods (@classmethod) now inherit the method attributes (__module__, __name__, __qualname__, __doc__, __annotations__) and have a new __wrapped__ attribute. Patch by Victor Stinner.

  • bpo-43751: Fixed a bug where anext(ait, default) would erroneously return None.

  • bpo-42128: __match_args__ is no longer allowed to be a list.

  • bpo-43683: Add GEN_START opcode. Marks start of generator, including async, or coroutine and handles sending values to a newly created generator or coroutine.

  • bpo-43105: Importlib now resolves relative paths when creating module spec objects from file locations.

  • bpo-43682: Static methods (@staticmethod) are now callable as regular functions. Patch by Victor Stinner.

  • bpo-42609: Prevented crashes in the AST validator and optimizer when compiling some absurdly long expressions like "+0"*1000000. RecursionError is now raised instead.

  • bpo-38530: When printing AttributeError, PyErr_Display() will offer suggestions of similar attribute names in the object that the exception was raised from. Patch by Pablo Galindo

Library

  • bpo-44015: In @dataclass(), raise a TypeError if KW_ONLY is specified more than once.

  • bpo-25478: Added a total() method to collections.Counter() to compute the sum of the counts.

  • bpo-43733: Change netrc.netrc to use UTF-8 encoding before using locale encoding.

  • bpo-43979: Removed an unnecessary list comprehension before looping from urllib.parse.parse_qsl(). Patch by Christoph Zwerschke and Dong-hee Na.

  • bpo-43993: Update bundled pip to 21.1.1.

  • bpo-43957: [Enum] Deprecate TypeError when non-member is used in a containment check; In 3.12 True or False will be returned instead, and containment will return True if the value is either a member of that enum or one of its members’ value.

  • bpo-42904: For backwards compatbility with previous minor versions of Python, if typing.get_type_hints() receives no namespace dictionary arguments, typing.get_type_hints() will search through the global then local namespaces during evaluation of stringized type annotations (string forward references) inside a class.

  • bpo-43945: [Enum] Deprecate non-standard mixin format() behavior: in 3.12 the enum member, not the member’s value, will be used for format() calls.

  • bpo-41139: Deprecate undocumented cgi.log() API.

  • bpo-43937: Fixed the turtle module working with non-default root window.

  • bpo-43930: Update bundled pip to 21.1 and setuptools to 56.0.0

  • bpo-43907: Fix a bug in the pure-Python pickle implementation when using protocol 5, where bytearray instances that occur several time in the pickled object graph would incorrectly unpickle into repeated copies of the bytearray object.

  • bpo-43926: In importlib.metadata, provide a uniform interface to Description, allow for any field to be encoded with multiline values, remove continuation lines from multiline values, and add a .json property for easy access to the PEP 566 JSON-compatible form. Sync with importlib_metadata 4.0.

  • bpo-43920: OpenSSL 3.0.0: load_verify_locations() now returns a consistent error message when cadata contains no valid certificate.

  • bpo-43607: urllib can now convert Windows paths with \\?\ prefixes into URL paths.

  • bpo-43817: Add inspect.get_annotations(), which safely computes the annotations defined on an object. It works around the quirks of accessing the annotations from various types of objects, and makes very few assumptions about the object passed in. inspect.get_annotations() can also correctly un-stringize stringized annotations.

    inspect.signature(), inspect.from_callable(), and inspect.from_function() now call inspect.get_annotations() to retrieve annotations. This means inspect.signature() and inspect.from_callable() can now un-stringize stringized annotations, too.

  • bpo-43284: platform.win32_ver derives the windows version from sys.getwindowsversion().platform_version which in turn derives the version from kernel32.dll (which can be of a different version than Windows itself). Therefore change the platform.win32_ver to determine the version using the platform module’s _syscmd_ver private function to return an accurate version.

  • bpo-42854: The ssl module now uses SSL_read_ex and SSL_write_ex internally. The functions support reading and writing of data larger than 2 GB. Writing zero-length data no longer fails with a protocol violation error.

  • bpo-42333: Port _ssl extension module to multiphase initialization.

  • bpo-43880: ssl now raises DeprecationWarning for OP_NO_SSL/TLS* options, old TLS versions, old protocols, and other features that have been deprecated since Python 3.6, 3.7, or OpenSSL 1.1.0.

  • bpo-41559: PEP 612 is now implemented purely in Python; builtin types.GenericAlias objects no longer include typing.ParamSpec in __parameters__ (with the exception of collections.abc.Callable‘s GenericAlias). This means previously invalid uses of ParamSpec (such as list[P]) which worked in earlier versions of Python 3.10 alpha, will now raise TypeError during substitution.

  • bpo-43867: The multiprocessing Server class now explicitly catchs SystemExit and closes the client connection in this case. It happens when the Server.serve_client() method reachs the end of file (EOF).

  • bpo-40443: Remove unused imports: pyclbr no longer uses copy, and typing no longer uses ast. Patch by Victor Stinner.

  • bpo-43820: Remove an unneeded copy of the namespace passed to dataclasses.make_dataclass().

  • bpo-43787: Add __iter__() method to bz2.BZ2File, gzip.GzipFile, and lzma.LZMAFile. It makes iterating them about 2x faster. Patch by Inada Naoki.

  • bpo-43680: Deprecate io.OpenWrapper and _pyio.OpenWrapper: use io.open and _pyio.open instead. Until Python 3.9, _pyio.open was not a static method and builtins.open was set to OpenWrapper to not become a bound method when set to a class variable. _io.open is a built-in function whereas _pyio.open is a Python function. In Python 3.10, _pyio.open() is now a static method, and builtins.open() is now io.open().

  • bpo-43680: The Python _pyio.open() function becomes a static method to behave as io.open() built-in function: don’t become a bound method when stored as a class variable. It becomes possible since static methods are now callable in Python 3.10. Moreover, _pyio.OpenWrapper() becomes a simple alias to _pyio.open(). Patch by Victor Stinner.

  • bpo-41515: Fix KeyError raised in typing.get_type_hints() due to synthetic modules that don’t appear in sys.modules.

  • bpo-43776: When subprocess.Popen args are provided as a string or as pathlib.Path, the Popen instance repr now shows the right thing.

  • bpo-42248: [Enum] ensure exceptions raised in _missing__ are released

  • bpo-43744: fix issue with enum member name matching the start of a private variable name

  • bpo-43772: Fixed the return value of TypeVar.__ror__. Patch by Jelle Zijlstra.

  • bpo-43764: Add match_args parameter to @dataclass decorator to allow suppression of __match_args__ generation.

  • bpo-43799: OpenSSL 3.0.0: define OPENSSL_API_COMPAT 1.1.1 to suppress deprecation warnings. Python requires OpenSSL 1.1.1 APIs.

  • bpo-43478: Mocks can no longer be used as the specs for other Mocks. As a result, an already-mocked object cannot have an attribute mocked using autospec=True or be the subject of a create_autospec(...) call. 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.

  • bpo-43794: Add ssl.OP_IGNORE_UNEXPECTED_EOF constants (OpenSSL 3.0.0)

  • bpo-43785: Improve bz2.BZ2File performance by removing the RLock from BZ2File. This makes BZ2File thread unsafe in the face of multiple simultaneous readers or writers, just like its equivalent classes in gzip and lzma have always been. Patch by Inada Naoki.

  • bpo-43789: OpenSSL 3.0.0: Don’t call the password callback function a second time when first call has signaled an error condition.

  • bpo-43788: The header files for ssl error codes are now OpenSSL version-specific. Exceptions will now show correct reason and library codes. The make_ssl_data.py script has been rewritten to use OpenSSL’s text file with error codes.

  • bpo-43766: Implement PEP 647 in the typing module by adding TypeGuard.

  • bpo-25264: os.path.realpath() now accepts a strict keyword-only argument. When set to True, OSError is raised if a path doesn’t exist or a symlink loop is encountered.

  • bpo-43780: In importlib.metadata, incorporate changes from importlib_metadata 3.10: Add mtime-based caching during distribution discovery. Flagged use of dict result from entry_points() as deprecated.

  • bpo-47383: The P.args and P.kwargs attributes of typing.ParamSpec are now instances of the new classes typing.ParamSpecArgs and typing.ParamSpecKwargs, which enables a more useful repr(). Patch by Jelle Zijlstra.

  • bpo-43731: Add an encoding parameter logging.fileConfig().

  • bpo-43712: Add encoding and errors parameters to fileinput.input() and fileinput.FileInput.

  • bpo-38659: A simple_enum decorator is added to the enum module to convert a normal class into an Enum. test_simple_enum added to test simple enums against a corresponding normal Enum. Standard library modules updated to use simple_enum.

  • bpo-43764: Fix an issue where __match_args__ generation could fail for some dataclasses.

  • bpo-43752: Fix sqlite3 regression for zero-sized blobs with converters, where b"" was returned instead of None. The regression was introduced by GH-24723. Patch by Erlend E. Aasland.

  • bpo-43655: tkinter dialog windows are now recognized as dialogs by window managers on macOS and X Window.

  • bpo-43723: The following threading methods are now deprecated and should be replaced:

    Patch by Jelle Zijlstra.

  • bpo-2135: Deprecate find_module() and find_loader() implementations in importlib and zipimport.

  • bpo-43534: turtle.textinput() and turtle.numinput() create now a transient window working on behalf of the canvas window.

  • bpo-43532: Add the ability to specify keyword-only fields to dataclasses. These fields will become keyword-only arguments to the generated __init__.

  • bpo-43522: Fix problem with hostname_checks_common_name. OpenSSL does not copy hostflags from struct SSL_CTX to struct SSL.

  • bpo-8978: Improve error message for tarfile.open() when lzma / bz2 are unavailable. Patch by Anthony Sottile.

  • bpo-42967: Allow bytes separator argument in urllib.parse.parse_qs and urllib.parse.parse_qsl when parsing str query strings. Previously, this raised a TypeError.

  • bpo-43296: Improve sqlite3 error handling: sqlite3_value_blob() errors that set SQLITE_NOMEM now raise MemoryError. Patch by Erlend E. Aasland.

  • bpo-43312: New functions sysconfig.get_preferred_scheme() and sysconfig.get_default_scheme() are added to query a platform for its preferred “user”, “home”, and “prefix” (default) scheme names.

  • bpo-43265: Improve sqlite3.Connection.backup() error handling. The error message for non-existant target database names is now unknown database <database name> instead of SQL logic error. Patch by Erlend E. Aasland.

  • bpo-41282: Install schemes in distutils.command.install are now loaded from sysconfig.

  • bpo-41282: distutils.sysconfig has been merged to sysconfig.

  • bpo-43176: Fixed processing of a dataclass that inherits from a frozen dataclass with no fields. It is now correctly detected as an error.

  • bpo-43080: pprint now has support for dataclasses.dataclass. Patch by Lewis Gaul.

  • bpo-39950: Add pathlib.Path.hardlink_to() method that supersedes link_to(). The new method has the same argument order as symlink_to().

  • bpo-42904: typing.get_type_hints() now checks the local namespace of a class when evaluating PEP 563 annotations inside said class.

  • bpo-42269: Add slots parameter to dataclasses.dataclass decorator to automatically generate __slots__ for class. Patch provided by Yurii Karabas.

  • bpo-39529: Deprecated use of asyncio.get_event_loop() without running event loop. Emit deprecation warning for asyncio functions which implicitly create a Future or Task objects if there is no running event loop and no explicit loop argument is passed: ensure_future(), wrap_future(), gather(), shield(), as_completed() and constructors of Future, Task, StreamReader, StreamReaderProtocol.

  • bpo-18369: Certificate and PrivateKey classes were added to the ssl module. Certificates and keys can now be loaded from memory buffer, too.

  • bpo-41486: Use a new output buffer management code for bz2 / lzma / zlib modules, and add .readall() function to _compression.DecompressReader class. These bring some performance improvements. Patch by Ma Lin.

  • bpo-31870: The ssl.get_server_certificate() function now has a timeout parameter.

  • bpo-41735: Fix thread locks in zlib module may go wrong in rare case. Patch by Ma Lin.

  • bpo-36470: Fix dataclasses with InitVars and replace(). Patch by Claudiu Popa.

  • bpo-40849: Expose X509_V_FLAG_PARTIAL_CHAIN ssl flag

  • bpo-35114: ssl.RAND_status() now returns a boolean value (as documented) instead of 1 or 0.

  • bpo-39906: pathlib.Path.stat() and chmod() now accept a follow_symlinks keyword-only argument for consistency with corresponding functions in the os module.

  • bpo-39899: os.path.expanduser() now refuses to guess Windows home directories if the basename of current user’s home directory does not match their username.

    pathlib.Path.expanduser() and home() now consistently raise RuntimeError exception when a home directory cannot be resolved. Previously a KeyError exception could be raised on Windows when the "USERNAME" environment variable was unset.

  • bpo-36076: Added SNI support to ssl.get_server_certificate().

  • bpo-38490: Covariance, Pearson’s correlation, and simple linear regression functionality was added to statistics module. Patch by Tymoteusz Wołodźko.

  • bpo-33731: Provide a locale.localize() function, which converts a normalized number string into a locale format.

  • bpo-32745: Fix a regression in the handling of ctypes’ ctypes.c_wchar_p type: embedded null characters would cause a ValueError to be raised. Patch by Zackery Spytz.

Documentation

  • bpo-43987: Add “Annotations Best Practices” document as a new HOWTO.

  • bpo-43977: Document the new Py_TPFLAGS_MAPPING and Py_TPFLAGS_SEQUENCE type flags.

  • bpo-43959: The documentation on the PyContextVar C-API was clarified.

  • bpo-43938: Update dataclasses documentation to express that FrozenInstanceError is derived from AttributeError.

  • bpo-43778: Fix the Sphinx glossary_search extension: create the _static/ sub-directory if it doesn’t exist.

  • bpo-43755: Update documentation to reflect that unparenthesized lambda expressions can no longer be the expression part in an if clause in comprehensions and generator expressions since Python 3.9.

  • bpo-43739: Fixing the example code in Doc/extending/extending.rst to declare and initialize the pmodule variable to be of the right type.

Tests

  • bpo-43961: Fix test_logging.test_namer_rotator_inheritance() on Windows: use os.replace() rather than os.rename(). Patch by Victor Stinner.

  • bpo-43842: Fix a race condition in the SMTP test of test_logging. Don’t close a file descriptor (socket) from a different thread while asyncore.loop() is polling the file descriptor. Patch by Victor Stinner.

  • bpo-43843: test.libregrtest now marks a test as ENV_CHANGED (altered the execution environment) if a thread raises an exception but does not catch it. It sets a hook on threading.excepthook(). Use --fail-env-changed option to mark the test as failed. Patch by Victor Stinner.

  • bpo-43811: Tests multiple OpenSSL versions on GitHub Actions. Use ccache to speed up testing.

  • bpo-43791: OpenSSL 3.0.0: Disable testing of legacy protocols TLS 1.0 and 1.1. Tests are failing with TLSV1_ALERT_INTERNAL_ERROR.

Build

  • bpo-43567: Improved generated code refresh (AST/tokens/opcodes/keywords) on Windows.

  • bpo-43669: Implement PEP 644. Python now requires OpenSSL 1.1.1 or newer.

Windows

  • bpo-35306: Adds additional arguments to os.startfile() function.

  • bpo-43538: Avoid raising errors from pathlib.Path.exists() when passed an invalid filename.

  • bpo-38822: Fixed os.stat() failing on inaccessible directories with a trailing slash, rather than falling back to the parent directory’s metadata. This implicitly affected os.path.exists() and os.path.isdir().

  • bpo-26227: Fixed decoding of host names in socket.gethostbyaddr() and socket.gethostbyname_ex().

  • bpo-40432: Updated pegen regeneration script on Windows to find and use Python 3.8 or higher. Prior to this, pegen regeneration already required 3.8 or higher, but the script may have used lower versions of Python.

  • bpo-43745: Actually updates Windows release to OpenSSL 1.1.1k. Earlier releases were mislabelled and actually included 1.1.1i again.

  • bpo-43652: Update Tcl and Tk to 8.6.11 in Windows installer.

  • bpo-43492: Upgrade Windows installer to use SQLite 3.35.5.

  • bpo-30555: Fix WindowsConsoleIO errors in the presence of fd redirection. Patch by Segev Finer.

macOS

  • bpo-42119: Fix check for macOS SDK paths when building Python. Narrow search to match contents of SDKs, namely only files in /System/Library, /System/IOSSupport, and /usr other than /usr/local. Previously, anything under /System was assumed to be in an SDK which causes problems with the new file system layout in 10.15+ where user file systems may appear to be mounted under /System. Paths in /Library were also incorrectly treated as SDK locations.

  • bpo-43568: Drop support for MACOSX_DEPLOYMENT_TARGET < 10.3

  • bpo-44009: Provide “python3.x-intel64” executable to allow reliably forcing macOS universal2 framework builds to run under Rosetta 2 Intel-64 emulation on Apple Silicon Macs. This can be useful for testing or when universal2 wheels are not yet available.

  • bpo-43851: Build SQLite with SQLITE_OMIT_AUTOINIT on macOS. Patch by Erlend E. Aasland.

  • bpo-43492: Update macOS installer to use SQLite 3.35.4.

  • bpo-42235: Mac/BuildScript/build-installer.py will now use “–enable-optimizations” and --with-lto when building on macOS 10.15 or later.

IDLE

  • bpo-37903: Add mouse actions to the shell sidebar. Left click and optional drag selects one or more lines, as with the editor line number sidebar. Right click after selecting raises a context menu with ‘copy with prompts’. This zips together prompts from the sidebar with lines from the selected text.

  • bpo-43981: Fix reference leak in test_squeezer. Patch by Pablo Galindo

  • bpo-37892: Indent IDLE Shell input with spaces instead of tabs

  • bpo-43655: IDLE dialog windows are now recognized as dialogs by window managers on macOS and X Window.

  • bpo-37903: IDLE’s shell now shows prompts in a separate side-bar.

C API

  • bpo-43916: Add a new Py_TPFLAGS_DISALLOW_INSTANTIATION type flag to disallow creating type instances. Patch by Victor Stinner.

  • bpo-43774: Remove the now unused PYMALLOC_DEBUG macro. Debug hooks on memory allocators are now installed by default if Python is built in debug mode (if Py_DEBUG macro is defined). Moreover, they can now be used on Python build in release mode (ex: using PYTHONMALLOC=debug environment variable).

  • bpo-43962: _PyInterpreterState_IDIncref() now calls _PyInterpreterState_IDInitref() and always increments id_refcount. Previously, calling _xxsubinterpreters.get_current() could create an id_refcount inconsistency when a _xxsubinterpreters.InterpreterID object was deallocated. Patch by Victor Stinner.

  • bpo-28254: Add new C-API functions to control the state of the garbage collector: PyGC_Enable(), PyGC_Disable(), PyGC_IsEnabled(), corresponding to the functions in the gc module.

  • bpo-43908: Introduce Py_TPFLAGS_IMMUTABLETYPE flag for immutable type objects, and modify PyType_Ready() to set it for static types. Patch by Erlend E. Aasland.

  • bpo-43795: PyMem_Calloc() is now available in the limited C API (Py_LIMITED_API).

  • bpo-43868: PyOS_ReadlineFunctionPointer() is no longer exported by limited C API headers and by python3.dll on Windows. Like any function that takes FILE*, it is not part of the stable ABI.

  • bpo-43795: Stable ABI and limited API definitions are generated from a central manifest (PEP 652).

  • bpo-43753: Add the Py_Is(x, y) function to test if the x object is the y object, the same as x is y in Python. Add also the Py_IsNone(), Py_IsTrue(), Py_IsFalse() functions to test if an object is, respectively, the None singleton, the True singleton or the False singleton. Patch by Victor Stinner.

Python 3.10.0 alpha 7

Release date: 2021-04-05

Security

  • bpo-42988: CVE-2021-3426: Remove the getfile feature of the pydoc module which could be abused to read arbitrary files on the disk (directory traversal vulnerability). Moreover, even source code of Python modules can contain sensitive data like passwords. Vulnerability reported by David Schwörer.

  • bpo-43285: ftplib no longer trusts the IP address value returned from the server in response to the PASV command by default. This prevents a malicious FTP server from using the response to probe IPv4 address and port combinations on the client network.

    Code that requires the former vulnerable behavior may set a trust_server_pasv_ipv4_address attribute on their ftplib.FTP instances to True to re-enable it.

  • bpo-43439: Add audit hooks for gc.get_objects(), gc.get_referrers() and gc.get_referents(). Patch by Pablo Galindo.

Core and Builtins

  • bpo-27129: Update CPython bytecode magic number.

  • bpo-43672: Raise ImportWarning when calling find_loader().

  • bpo-43660: Fix crash that happens when replacing sys.stderr with a callable that can remove the object while an exception is being printed. Patch by Pablo Galindo.

  • bpo-27129: The bytecode interpreter uses instruction, rather byte, offsets internally. This reduces the number of EXTENDED_ARG instructions needed and streamlines instruction dispatch a bit.

  • bpo-40645: Fix reference leak in the _hashopenssl extension. Patch by Pablo Galindo.

  • bpo-42134: Calls to find_module() by the import system now raise ImportWarning.

  • bpo-41064: Improve the syntax error for invalid usage of double starred elements (‘**’) in f-strings. Patch by Pablo Galindo.

  • bpo-43575: Speed up calls to map() by using the PEP 590 vectorcall calling convention. Patch by Dong-hee Na.

  • bpo-42137: The import system now prefers using __spec__ for ModuleType.__repr__ over module_repr().

  • bpo-43452: Added micro-optimizations to _PyType_Lookup() to improve cache lookup performance in the common case of cache hits.

  • bpo-43555: Report the column offset for SyntaxError for invalid line continuation characters. Patch by Pablo Galindo.

  • bpo-43517: Fix misdetection of circular imports when using from pkg.mod import attr, which caused false positives in non-trivial multi-threaded code.

  • bpo-43497: Emit SyntaxWarnings for assertions with tuple constants, this is a regression introduced in python3.7

  • bpo-39316: Tracing now has correct line numbers for attribute accesses when the the attribute is on a different line from the object. Improves debugging and profiling for multi-line method chains.

  • bpo-35883: Python no longer fails at startup with a fatal error if a command line argument contains an invalid Unicode character. The Py_DecodeLocale() function now escapes byte sequences which would be decoded as Unicode characters outside the [U+0000; U+10ffff] range.

  • bpo-43410: Fix a bug that was causing the parser to crash when emiting syntax errors when reading input from stdin. Patch by Pablo Galindo

  • bpo-43406: Fix a possible race condition where PyErr_CheckSignals tries to execute a non-Python signal handler.

  • bpo-42128: Add __match_args__ to structsequence based classes. Patch by Pablo Galindo.

  • bpo-43390: CPython now sets the SA_ONSTACK flag in PyOS_setsig for the VM’s default signal handlers. This is friendlier to other in-process code that an extension module or embedding use could pull in (such as Golang’s cgo) where tiny thread stacks are the norm and sigaltstack() has been used to provide for signal handlers. This is a no-op change for the vast majority of processes that don’t use sigaltstack.

  • bpo-43287: Speed up calls to filter() by using the PEP 590 vectorcall calling convention. Patch by Dong-hee Na.

  • bpo-37448: Add a radix tree based memory map to track in-use obmalloc arenas. Use to replace the old implementation of address_in_range(). The radix tree approach makes it easy to increase pool sizes beyond the OS page size. Boosting the pool and arena size allows obmalloc to handle a significantly higher percentage of requests from its ultra-fast paths.

    It also has the advantage of eliminating the memory unsanitary behavior of the previous address_in_range(). The old address_in_range() was marked with the annotations _Py_NO_SANITIZE_ADDRESS, _Py_NO_SANITIZE_THREAD, and _Py_NO_SANITIZE_MEMORY. Those annotations are no longer needed.

    To disable the radix tree map, set a preprocessor flag as follows: -DWITH_PYMALLOC_RADIX_TREE=0.

    Co-authored-by: Tim Peters <tim.peters@gmail.com>

  • bpo-29988: Only handle asynchronous exceptions and requests to drop the GIL when returning from a call or on the back edges of loops. Makes sure that __exit__() is always called in with statements, even for interrupts.

Library

  • bpo-43720: Document various stdlib deprecations in imp, pkgutil, and importlib.util for removal in Python 3.12.

  • bpo-43433: xmlrpc.client.ServerProxy no longer ignores query and fragment in the URL of the server.

  • bpo-31956: The index() method of array.array now has optional start and stop parameters.

  • bpo-40066: Enum: adjust repr() to show only enum and member name (not value, nor angle brackets) and str() to show only member name. Update and improve documentation to match.

  • bpo-42136: Deprecate all module_repr() methods found in importlib as their use is being phased out by Python 3.12.

  • bpo-35930: Raising an exception raised in a “future” instance will create reference cycles.

  • bpo-41369: Finish updating the vendored libmpdec to version 2.5.1. Patch by Stefan Krah.

  • bpo-43422: Revert the _decimal C API which was added in bpo-41324.

  • bpo-43577: Fix deadlock when using ssl.SSLContext debug callback with ssl.SSLContext.sni_callback().

  • bpo-43571: It’s now possible to create MPTCP sockets with IPPROTO_MPTCP

  • bpo-43542: image/heic and image/heif were added to mimetypes.

  • bpo-40645: The hmac module now uses OpenSSL’s HMAC implementation when digestmod argument is a hash name or builtin hash function.

  • bpo-43510: Implement PEP 597: Add EncodingWarning warning, -X warn_default_encoding option, PYTHONWARNDEFAULTENCODING environment variable and encoding="locale" argument value.

  • bpo-43521: ast.unparse can now render NaNs and empty sets.

  • bpo-42914: pprint.pprint() gains a new boolean underscore_numbers optional argument to emit integers with thousands separated by an underscore character for improved readability (for example 1_000_000 instead of 1000000).

  • bpo-41361: rotate() calls are now slightly faster due to faster argument parsing.

  • bpo-43423: subprocess.communicate() no longer raises an IndexError when there is an empty stdout or stderr IO buffer during a timeout on Windows.

  • bpo-27820: Fixed long-standing bug of smtplib.SMTP where doing AUTH LOGIN with initial_response_ok=False will fail.

    The cause is that SMTP.auth_login _always_ returns a password if provided with a challenge string, thus non-compliant with the standard for AUTH LOGIN.

    Also fixes bug with the test for smtpd.

  • bpo-43445: Add frozen modules to sys.stdlib_module_names. For example, add "_frozen_importlib" and "_frozen_importlib_external" names.

  • bpo-43245: Add keyword arguments support to ChainMap.new_child().

  • bpo-29982: Add optional parameter ignore_cleanup_errors to tempfile.TemporaryDirectory() and allow multiple cleanup() attempts. Contributed by C.A.M. Gerlach.

  • bpo-43428: Include changes from importlib_metadata 3.7:

    Performance enhancements to distribution discovery.

    entry_points only returns unique distributions.

    Introduces new EntryPoints object for containing a set of entry points with convenience methods for selecting entry points by group or name. entry_points now returns this object if selection parameters are supplied but continues to return a dict object for compatibility. Users are encouraged to rely on the selection interface. The dict object result is likely to be deprecated in the future.

    Added packages_distributions function to return a mapping of packages to the distributions that provide them.

  • bpo-43332: Improves the networking efficiency of http.client when using a proxy via set_tunnel(). Fewer small send calls are made during connection setup.

  • bpo-43420: Improve performance of fractions.Fraction arithmetics for large components. Contributed by Sergey B. Kirpichev.

  • bpo-43356: Allow passing a signal number to _thread.interrupt_main().

  • bpo-43399: Fix ElementTree.extend not working on iterators when using the Python implementation

  • bpo-43369: Improve sqlite3 error handling: If sqlite3_column_text() and sqlite3_column_blob() set SQLITE_NOMEM, MemoryError is now raised. Patch by Erlend E. Aasland.

  • bpo-43368: Fix a regression introduced in GH-24562, where an empty bytestring was fetched as None instead of b'' in sqlite3. Patch by Mariusz Felisiak.

  • bpo-41282: Fixed stacklevel of DeprecationWarning emitted from import distutils.

  • bpo-42129: importlib.resources now honors namespace packages, merging resources from each location in the namespace as introduced in importlib_resources 3.2 and including incidental changes through 5.0.3.

  • bpo-43295: datetime.datetime.strptime() now raises ValueError instead of IndexError when matching 'z' with the %z format specifier.

  • bpo-43125: Return empty string if base64mime.body_encode receive empty bytes

  • bpo-43084: curses.window.enclose() returns now True or False (as was documented) instead of 1 or 0.

  • bpo-42994: Add MIME types for opus, AAC, 3gpp and 3gpp2

  • bpo-14678: Add an invalidate_caches() method to the zipimport.zipimporter class to support importlib.invalidate_caches(). Patch by Desmond Cheong.

  • bpo-42782: Fail fast in shutil.move() to avoid creating destination directories on failure.

  • bpo-40066: Enum’s repr() and str() have changed: repr() is now EnumClass.MemberName and str() is MemberName. Additionally, stdlib Enum’s whose contents are available as module attributes, such as RegexFlag.IGNORECASE, have their repr() as module.name, e.g. re.IGNORECASE.

  • bpo-26053: Fixed bug where the pdb interactive run command echoed the args from the shell command line, even if those have been overridden at the pdb prompt.

  • bpo-24160: Fixed bug where breakpoints did not persist across multiple debugger sessions in pdb’s interactive mode.

  • bpo-40701: When the tempfile.tempdir global variable is set to a value of type bytes, it is now handled consistently. Previously exceptions could be raised from some tempfile APIs when the directory did not already exist in this situation. Also ensures that the tempfile.gettempdir() and tempfile.gettempdirb() functions always return str and bytes respectively.

  • bpo-39342: Expose X509_V_FLAG_ALLOW_PROXY_CERTS as VERIFY_ALLOW_PROXY_CERTS to allow proxy certificate validation as explained in https://www.openssl.org/docs/man1.1.1/man7/proxy-certificates.html.

  • bpo-31861: Add builtins.aiter and builtins.anext. Patch by Joshua Bronson (@jab), Daniel Pope (@lordmauve), and Justin Wang (@justin39).

Documentation

Tests

  • bpo-37945: Fix test_getsetlocale_issue1813() of test_locale: skip the test if setlocale() fails. Patch by Victor Stinner.

  • bpo-41561: Add workaround for Ubuntu’s custom OpenSSL security level policy.

Build

  • bpo-43179: Introduce and correctly use ALIGNOF_X in place of SIZEOF_X for alignment-related code in optimized string routines. Patch by Jessica Clarke.

  • bpo-43631: Update macOS, Windows, and CI to OpenSSL 1.1.1k.

  • bpo-43617: Improve configure.ac: Check for presence of autoconf-archive package and remove our copies of M4 macros.

  • bpo-43466: The configure script now supports --with-openssl-rpath option.

  • bpo-43372: Use _freeze_importlib to generate code for the __hello__ module. This approach ensures the code matches the interpreter version. Previously, PYTHON_FOR_REGEN was used to generate the code, which might be wrong. The marshal format for code objects has changed with bpo-42246, commit 877df851. Update the code and the expected code sizes in ctypes test_frozentable.

Windows

  • bpo-43440: Build sqlite3 with the R*Tree module enabled. Patch by Erlend E. Aasland.

IDLE

  • bpo-42225: Document that IDLE can fail on Unix either from misconfigured IP masquerage rules or failure displaying complex colored (non-ascii) characters.

C API

  • bpo-43688: The limited C API is now supported if Python is built in debug mode (if the Py_DEBUG macro is defined). In the limited C API, the Py_INCREF() and Py_DECREF() functions are now implemented as opaque function calls, rather than accessing directly the PyObject.ob_refcnt member, if Python is built in debug mode and the Py_LIMITED_API macro targets Python 3.10 or newer. It became possible to support the limited C API in debug mode because the PyObject structure is the same in release and debug mode since Python 3.8 (see bpo-36465).

    The limited C API is still not supported in the --with-trace-refs special build (Py_TRACE_REFS macro).

    Patch by Victor Stinner.

  • bpo-43244: Remove the pyarena.h header file with functions:

    • PyArena_New()

    • PyArena_Free()

    • PyArena_Malloc()

    • PyArena_AddPyObject()

    These functions were undocumented, excluded from the limited C API, and were only used internally by the compiler. Patch by Victor Stinner.

  • bpo-43244: Remove the compiler and parser functions using struct _mod type, because the public AST C API was removed:

    • PyAST_Compile()

    • PyAST_CompileEx()

    • PyAST_CompileObject()

    • PyFuture_FromAST()

    • PyFuture_FromASTObject()

    • PyParser_ASTFromFile()

    • PyParser_ASTFromFileObject()

    • PyParser_ASTFromFilename()

    • PyParser_ASTFromString()

    • PyParser_ASTFromStringObject()

    These functions were undocumented and excluded from the limited C API. Patch by Victor Stinner.

  • bpo-43244: Remove ast.h, asdl.h, and Python-ast.h header files. These functions were undocumented and excluded from the limited C API. Most names defined by these header files were not prefixed by Py and so could create names conflicts. For example, Python-ast.h defined a Yield macro which was conflict with the Yield name used by the Windows <winbase.h> header. Use the Python ast module instead. Patch by Victor Stinner.

  • bpo-43541: Fix a PyEval_EvalCodeEx() regression: fix reference counting on builtins. Patch by Victor Stinner.

  • bpo-43244: Remove the symtable.h header file and the undocumented functions:

    • PyST_GetScope()

    • PySymtable_Build()

    • PySymtable_BuildObject()

    • PySymtable_Free()

    • Py_SymtableString()

    • Py_SymtableStringObject()

    The Py_SymtableString() function was part the stable ABI by mistake but it could not be used, because the symtable.h header file was excluded from the limited C API.

    The Python symtable module remains available and is unchanged.

    Patch by Victor Stinner.

  • bpo-43244: Remove the PyAST_Validate() function. It is no longer possible to build a AST object (mod_ty type) with the public C API. The function was already excluded from the limited C API (PEP 384). Patch by Victor Stinner.

Python 3.10.0 alpha 6

Release date: 2021-03-01

Security

  • bpo-42967: Fix web cache poisoning vulnerability by defaulting the query args separator to &, and allowing the user to choose a custom separator.

Core and Builtins

  • bpo-43321: Fix SystemError raised when PyArg_Parse*() is used with # but without PY_SSIZE_T_CLEAN defined.

  • bpo-36346: PyArg_Parse*() functions now emits DeprecationWarning when u or Z format is used. See PEP 623 for detail.

  • bpo-43277: Add a new PySet_CheckExact() function to the C-API to check if an object is an instance of set but not an instance of a subtype. Patch by Pablo Galindo.

  • bpo-42990: The types.FunctionType constructor now inherits the current builtins if the globals dictionary has no "__builtins__" key, rather than using {"None": None} as builtins: same behavior as eval() and exec() functions. Defining a function with def function(...): ... in Python is not affected, globals cannot be overriden with this syntax: it also inherits the current builtins. Patch by Victor Stinner.

  • bpo-42990: Functions have a new __builtins__ attribute which is used to look for builtin symbols when a function is executed, instead of looking into __globals__['__builtins__']. Patch by Mark Shannon and Victor Stinner.

  • bpo-43149: Improve the error message in the parser for exception groups without parentheses. Patch by Pablo Galindo.

  • bpo-43121: Fixed an incorrect SyntaxError message for missing comma in literals. Patch by Pablo Galindo.

  • bpo-42819: readline: Explicitly disable bracketed paste in the interactive interpreter, even if it’s set in the inputrc, is enabled by default (eg GNU Readline 8.1), or a user calls readline.read_init_file(). The Python REPL has not implemented bracketed paste support. Also, bracketed mode writes the "\x1b[?2004h" escape sequence into stdout which causes test failures in applications that don’t support it. It can still be explicitly enabled by calling readline.parse_and_bind("set enable-bracketed-paste on"). Patch by Dustin Rodrigues.

  • bpo-42808: Simple calls to type(object) are now faster due to the vectorcall calling convention. Patch by Dennis Sweeney.

  • bpo-42217: Make the compiler merges same co_code and co_linetable objects in a module like already did for co_consts.

  • bpo-41972: Substring search functions such as str1 in str2 and str2.find(str1) now sometimes use the “Two-Way” string comparison algorithm to avoid quadratic behavior on long strings.

  • bpo-42128: Implement PEP 634 (structural pattern matching). Patch by Brandt Bucher.

  • bpo-40692: In the concurrent.futures.ProcessPoolExecutor, validate that multiprocess.synchronize() is available on a given platform and rely on that check in the concurrent.futures test suite so we can run tests that are unrelated to ProcessPoolExecutor on those platforms.

  • bpo-38302: If object.__ipow__() returns NotImplemented, the operator will correctly fall back to object.__pow__() and object.__rpow__() as expected.

Library

  • bpo-43316: The python -m gzip command line application now properly fails when detecting an unsupported extension. It exits with a non-zero exit code and prints an error message to stderr.

  • bpo-43317: Set the chunk size for the gzip module main function to io.DEFAULT_BUFFER_SIZE. This is slightly faster than the 1024 bytes constant that was used previously.

  • bpo-43146: Handle None in single-arg versions of print_exception() and format_exception().

  • bpo-43260: Fix TextIOWrapper can not flush internal buffer forever after very large text is written.

  • bpo-43258: Prevent needless allocation of sqlite3 aggregate function context when no rows match an aggregate query. Patch by Erlend E. Aasland.

  • bpo-43251: Improve sqlite3 error handling: sqlite3_column_name() failures now result in MemoryError. Patch by Erlend E. Aasland.

  • bpo-40956: Fix segfault in sqlite3.Connection.backup() if no argument was provided. The regression was introduced by GH-23838. Patch by Erlend E. Aasland.

  • bpo-43172: The readline module now passes its tests when built directly against libedit. Existing irreconcilable API differences remain in readline.get_begidx() and readline.get_endidx() behavior based on libreadline vs libedit use.

  • bpo-43163: Fix a bug in codeop that was causing it to not ask for more input when multi-line snippets have unclosed parentheses. Patch by Pablo Galindo

  • bpo-43162: deprecate unsupported ability to access enum members as attributes of other enum members

  • bpo-43146: Fix recent regression in None argument handling in traceback module functions.

  • bpo-43102: The namedtuple __new__ method had its __builtins__ set to None instead of an actual dictionary. This created problems for introspection tools.

  • bpo-43106: Added O_EVTONLY, O_FSYNC, O_SYMLINK and O_NOFOLLOW_ANY for macOS. Patch by Dong-hee Na.

  • bpo-42960: Adds resource.RLIMIT_KQUEUES constant from FreeBSD to the resource module.

  • bpo-42151: Make the pure Python implementation of xml.etree.ElementTree behave the same as the C implementation (_elementree) regarding default attribute values (by not setting specified_attributes=1).

  • bpo-29753: In ctypes, now packed bitfields are calculated properly and the first item of packed bitfields is now shrank correctly.

Documentation

  • bpo-27646: Clarify that ‘yield from <expr>’ works with any iterable, not just iterators.

  • bpo-36346: Update some deprecated unicode APIs which are documented as “will be removed in 4.0” to “3.12”. See PEP 623 for detail.

Tests

  • bpo-43288: Fix test_importlib to correctly skip Unicode file tests if the fileystem does not support them.

Build

  • bpo-43174: Windows build now uses /utf-8 compiler option.

  • bpo-43103: Add a new configure --without-static-libpython option to not build the libpythonMAJOR.MINOR.a static library and not install the python.o object file.

  • bpo-13501: The configure script can now use libedit instead of readline with the command line option --with-readline=editline.

  • bpo-42603: Make configure script use pkg-config to detect the location of Tcl/Tk headers and libraries, used to build tkinter.

    On macOS, a Tcl/Tk configuration provided by pkg-config will be preferred over Tcl/Tk frameworks installed in /{System/,}Library/Frameworks. If both exist and the latter is preferred, the appropriate --with-tcltk-* configuration options need to be explicitly set.

  • bpo-39448: Add the “regen-frozen” makefile target that regenerates the code for the frozen __hello__ module.

Windows

  • bpo-43155: PyCMethod_New() is now present in python3.lib.

macOS

  • bpo-41837: Update macOS installer build to use OpenSSL 1.1.1j.

IDLE

  • bpo-43283: Document why printing to IDLE’s Shell is often slower than printing to a system terminal and that it can be made faster by pre-formatting a single string before printing.

C API

  • bpo-43278: Always put compiler and system information on the first line of the REPL welcome message.

  • bpo-43270: Remove the private _PyErr_OCCURRED() macro: use the public PyErr_Occurred() function instead.

  • bpo-35134: Move odictobject.h, parser_interface.h, picklebufobject.h, pydebug.h, and pyfpe.h into the cpython/ directory. They must not be included directly, as they are already included by Python.h: Include Files.

  • bpo-35134: Move pyarena.h, pyctype.h, and pytime.h into the cpython/ directory. They must not be included directly, as they are already included by Python.h: Include Files.

  • bpo-40170: PyExceptionClass_Name() is now always declared as a function, in order to hide implementation details. The macro accessed PyTypeObject.tp_name directly. Patch by Erlend E. Aasland.

  • bpo-43239: The PyCFunction_New() function is now exported in the ABI when compiled with -fvisibility=hidden.

  • bpo-40170: PyIter_Check() is now always declared as a function, in order to hide implementation details. The macro accessed PyTypeObject.tp_iternext directly. Patch by Erlend E. Aasland.

  • bpo-40170: Convert PyDescr_IsData() macro to a function to hide implementation details: The macro accessed PyTypeObject.tp_descr_set directly. Patch by Erlend E. Aasland.

  • bpo-43181: Convert PyObject_TypeCheck() macro to a static inline function. Patch by Erlend E. Aasland.

Python 3.10.0 alpha 5

Release date: 2021-02-02

Security

Core and Builtins

  • bpo-42990: Refactor the PyEval_ family of functions.

    • An new function _PyEval_Vector is added to simplify calls to Python from C.

    • _PyEval_EvalCodeWithName is removed

    • PyEval_EvalCodeEx is retained as part of the API, but is not used internally

  • bpo-38631: Replace Py_FatalError() calls in the compiler with regular SystemError exceptions. Patch by Victor Stinner.

  • bpo-42997: Improve error message for missing “:” before blocks. Patch by Pablo Galindo.

  • bpo-43017: Improve error message in the parser when using un-parenthesised tuples in comprehensions. Patch by Pablo Galindo.

  • bpo-42986: Fix parser crash when reporting syntax errors in f-string with newlines. Patch by Pablo Galindo.

  • bpo-40176: Syntax errors for unterminated string literals now point to the start of the string instead of reporting EOF/EOL.

  • bpo-42927: The inline cache for LOAD_ATTR now also optimizes access to attributes defined by __slots__. This makes reading such attribute up to 30% faster.

  • bpo-42864: Improve error messages in the parser when parentheses are not closed. Patch by Pablo Galindo.

  • bpo-42924: Fix bytearray repetition incorrectly copying data from the start of the buffer, even if the data is offset within the buffer (e.g. after reassigning a slice at the start of the bytearray to a shorter byte string).

  • bpo-42882: Fix the _PyUnicode_FromId() function (_Py_IDENTIFIER(var) API) when Py_Initialize() / Py_Finalize() is called multiple times: preserve _PyRuntime.unicode_ids.next_index value.

  • bpo-42827: Fix a crash when working out the error line of a SyntaxError in some multi-line expressions.

  • bpo-42823: frame.f_lineno is correct even if frame.f_trace is set to True

  • bpo-37324: Remove deprecated aliases to Collections Abstract Base Classes from the collections module.

  • bpo-41994: Fixed possible leak in import when sys.modules is not a dict.

  • bpo-27772: In string formatting, preceding the width field by '0' no longer affects the default alignment for strings.

Library

  • bpo-43108: Fixed a reference leak in the curses module. Patch by Pablo Galindo

  • bpo-43077: Update the bundled pip to 21.0.1 and setuptools to 52.0.0.

  • bpo-41282: Deprecate distutils in documentation and add warning on import.

  • bpo-43014: Improve performance of tokenize by 20-30%. Patch by Anthony Sottile.

  • bpo-42323: Fix math.nextafter() for NaN on AIX.

  • bpo-42955: Add sys.stdlib_module_names, containing the list of the standard library module names. Patch by Victor Stinner.

  • bpo-42944: Fix random.Random.sample when counts argument is not None.

  • bpo-42934: Use TracebackException’s new compact param in TestResult to reduce time and memory consumed by traceback formatting.

  • bpo-42931: Add randbytes() to random.__all__.

  • bpo-38250: [Enum] Flags consisting of a single bit are now considered canonical, and will be the only flags returned from listing and iterating over a Flag class or a Flag member. Multi-bit flags are considered aliases; they will be returned from lookups and operations that result in their value. Iteration for both Flag and Flag members is in definition order.

  • bpo-42877: Added the compact parameter to the constructor of traceback.TracebackException to reduce time and memory for use cases that only need to call TracebackException.format() and TracebackException.format_exception_only().

  • bpo-42923: The Py_FatalError() function and the faulthandler module now dump the list of extension modules on a fatal error.

  • bpo-42848: Removed recursion from TracebackException to allow it to handle long exception chains.

  • bpo-42901: [Enum] move member creation from EnumMeta.__new__ to _proto_member.__set_name__, allowing members to be created and visible in __init_subclass__.

  • bpo-42780: Fix os.set_inheritable() for O_PATH file descriptors on Linux.

  • bpo-42866: Fix a reference leak in the getcodec() function of CJK codecs. Patch by Victor Stinner.

  • bpo-42846: Convert the 6 CJK codec extension modules (_codecs_cn, _codecs_hk, _codecs_iso2022, _codecs_jp, _codecs_kr and _codecs_tw) to the multiphase initialization API (PEP 489). Patch by Victor Stinner.

  • bpo-42851: remove __init_subclass__ support for Enum members

  • bpo-42834: Make internal caches of the _json module compatible with subinterpreters.

  • bpo-41748: Fix HTMLParser parsing rules for element attributes containing commas with spaces. Patch by Karl Dubost.

  • bpo-40810: Require SQLite 3.7.15 or newer. Patch by Erlend E. Aasland.

  • bpo-1635741: Convert the _multibytecodec extension module (CJK codecs) to multi-phase initialization (PEP 489). Patch by Erlend E. Aasland.

  • bpo-42802: The distutils bdist_wininst command deprecated in Python 3.8 has been removed. The distutils bdist_wheel command is now recommended to distribute binary packages on Windows.

  • bpo-24464: The undocumented built-in function sqlite3.enable_shared_cache is now deprecated, scheduled for removal in Python 3.12. Its use is strongly discouraged by the SQLite3 documentation. Patch by Erlend E. Aasland.

  • bpo-42384: Make pdb populate sys.path[0] exactly the same as regular python execution.

  • bpo-42383: Fix pdb: previously pdb would fail to restart the debugging target if it was specified using a relative path and the current directory changed.

  • bpo-42005: Fix CLI of cProfile and profile to catch BrokenPipeError.

  • bpo-41604: Don’t decrement the reference count of the previous user_ptr when set_panel_userptr fails.

  • bpo-41149: Allow executing callables that have a boolean value of False when passed to Threading.thread as the target. Patch contributed by Barney Stratford.

  • bpo-38307: Add an ‘end_lineno’ attribute to the Class and Function objects that appear in the tree returned by pyclbr functions. This and the existing ‘lineno’ attribute define the extent of class and def statements. Patch by Aviral Srivastava.

  • bpo-39273: The BUTTON5_* constants are now exposed in the curses module if available.

  • bpo-33289: Correct call to tkinter.colorchooser to return RGB triplet of ints instead of floats. Patch by Cheryl Sabella.

Documentation

  • bpo-40304: Fix doc for type(name, bases, dict). Patch by Boris Verkhovskiy and Éric Araujo.

  • bpo-42811: Updated importlib.utils.resolve_name() doc to use __spec__.parent instead of __package__. (Thanks Yair Frid.)

Tests

  • bpo-40823: Use unittest.TestLoader().loadTestsFromTestCase() instead of unittest.makeSuite() in sqlite3 tests. Patch by Erlend E. Aasland.

  • bpo-40810: In sqlite3, fix CheckTraceCallbackContent for SQLite pre 3.7.15.

Build

  • bpo-43031: Pass --timeout=$(TESTTIMEOUT) option to the default profile task ./python -m test --pgo command.

  • bpo-36143: make regen-all now also runs regen-keyword. Patch by Victor Stinner.

  • bpo-42874: Removed the grep -q and -E flags in the tzpath validation section of the configure script to better accomodate users of some platforms (specifically Solaris 10).

  • bpo-31904: Add library search path by wr-cc in add_cross_compiling_paths() for VxWorks.

  • bpo-42856: Add --with-wheel-pkg-dir=PATH option to the ./configure script. If specified, the ensurepip module looks for setuptools and pip wheel packages in this directory: if both are present, these wheel packages are used instead of ensurepip bundled wheel packages.

    Some Linux distribution packaging policies recommend against bundling dependencies. For example, Fedora installs wheel packages in the /usr/share/python-wheels/ directory and don’t install the ensurepip._bundled package.

Windows

  • bpo-41837: Updated Windows installer to include OpenSSL 1.1.1i

  • bpo-42584: Upgrade Windows installer to use SQLite 3.34.0.

macOS

  • bpo-42504: Ensure that the value of sysconfig.get_config_var(‘MACOSX_DEPLOYMENT_TARGET’) is always a string, even in when the value is parsable as an integer.

IDLE

  • bpo-43008: Make IDLE invoke sys.excepthook() in normal, 2-process mode. Patch by Ken Hilton.

  • bpo-33065: Fix problem debugging user classes with __repr__ method.

  • bpo-23544: Disable Debug=>Stack Viewer when user code is running or Debugger is active, to prevent hang or crash. Patch by Zackery Spytz.

  • bpo-32631: Finish zzdummy example extension module: make menu entries work; add docstrings and tests with 100% coverage.

C API

  • bpo-42979: When Python is built in debug mode (with C assertions), calling a type slot like sq_length (__len__() in Python) now fails with a fatal error if the slot succeeded with an exception set, or failed with no exception set. The error message contains the slot, the type name, and the current exception (if an exception is set). Patch by Victor Stinner.

  • bpo-43030: Fixed a compiler warning in Py_UNICODE_ISSPACE() on platforms with signed wchar_t.

Python 3.10.0 alpha 4

Release date: 2021-01-04

Core and Builtins

  • bpo-42814: Fix undefined behavior in Objects/genericaliasobject.c.

  • bpo-42806: Fix the column offsets for f-strings ast nodes surrounded by parentheses and for nodes that spawn multiple lines. Patch by Pablo Galindo.

  • bpo-40631: Fix regression where a single parenthesized starred expression was a valid assignment target.

  • bpo-27794: Improve the error message for failed writes/deletes to property objects. When possible, the attribute name is now shown. Patch provided by Yurii Karabas.

  • bpo-42745: Make the type attribute lookup cache per-interpreter. Patch by Victor Stinner.

  • bpo-42246: Jumps to jumps are not eliminated when it would break PEP 626.

  • bpo-42246: Make sure that the f_lasti and f_lineno attributes of a frame are set correctly when an exception is raised or re-raised. Required for PEP 626.

  • bpo-32381: The coding cookie (ex: # coding: latin1) is now ignored in the command passed to the -c command line option. Patch by Victor Stinner.

  • bpo-30858: Improve error location in expressions that contain assignments. Patch by Pablo Galindo and Lysandros Nikolaou.

  • bpo-42615: Remove jump commands made redundant by the deletion of unreachable bytecode blocks

  • bpo-42639: Make the atexit module state per-interpreter. It is now safe have more than one atexit module instance. Patch by Dong-hee Na and Victor Stinner.

  • bpo-32381: Fix encoding name when running a .pyc file on Windows: PyRun_SimpleFileExFlags() now uses the correct encoding to decode the filename.

  • bpo-42195: The __args__ of the parameterized generics for typing.Callable and collections.abc.Callable are now consistent. The __args__ for collections.abc.Callable are now flattened while typing.Callable’s have not changed. To allow this change, types.GenericAlias can now be subclassed and collections.abc.Callable’s __class_getitem__ will now return a subclass of types.GenericAlias. Tests for typing were also updated to not subclass things like Callable[..., T] as that is not a valid base class. Finally, both Callables no longer validate their argtypes, in Callable[[argtypes], resulttype] to prepare for PEP 612. Patch by Ken Jin.

  • bpo-40137: Convert functools module to use PyType_FromModuleAndSpec().

  • bpo-40077: Convert array to use heap types, and establish module state for these.

  • bpo-42008: Fix _random.Random() seeding.

  • bpo-1635741: Port the pyexpat extension module to multi-phase initialization (PEP 489).

  • bpo-40521: Make the Unicode dictionary of interned strings compatible with subinterpreters. Patch by Victor Stinner.

  • bpo-39465: Make _PyUnicode_FromId() function compatible with subinterpreters. Each interpreter now has an array of identifier objects (interned strings decoded from UTF-8). Patch by Victor Stinner.

Library

  • bpo-42257: Handle empty string in variable executable in platform.libc_ver()

  • bpo-42772: randrange() now raises a TypeError when step is specified without a stop argument. Formerly, it silently ignored the step argument.

  • bpo-42759: Fixed equality comparison of tkinter.Variable and tkinter.font.Font. Objects which belong to different Tcl interpreters are now always different, even if they have the same name.

  • bpo-42756: Configure LMTP Unix-domain socket to use socket global default timeout when a timeout is not explicitly provided.

  • bpo-23328: Allow / character in username, password fields on _PROXY envars.

  • bpo-42740: typing.get_args() and typing.get_origin() now support PEP 604 union types and PEP 612 additions to Callable.

  • bpo-42655: subprocess extra_groups is now correctly passed into setgroups() system call.

  • bpo-42727: EnumMeta.__prepare__ now accepts **kwds to properly support __init_subclass__

  • bpo-38308: Add optional weights to statistics.harmonic_mean().

  • bpo-42721: When simple query dialogs (tkinter.simpledialog), message boxes (tkinter.messagebox) or color choose dialog (tkinter.colorchooser) are created without arguments master and parent, and the default root window is not yet created, and NoDefaultRoot() was not called, a new temporal hidden root window will be created automatically. It will not be set as the default root window and will be destroyed right after closing the dialog window. It will help to use these simple dialog windows in programs which do not need other GUI.

  • bpo-25246: Optimized collections.deque.remove().

  • bpo-35728: Added a root parameter to tkinter.font.nametofont().

  • bpo-15303: tkinter supports now widgets with boolean value False.

  • bpo-42681: Fixed range checks for color and pair numbers in curses.

  • bpo-42685: Improved placing of simple query windows in Tkinter (such as tkinter.simpledialog.askinteger()). They are now centered at the center of the parent window if it is specified and shown, otherwise at the center of the screen.

  • bpo-9694: Argparse help no longer uses the confusing phrase, “optional arguments”. It uses “options” instead.

  • bpo-1635741: Port the _thread extension module to the multiphase initialization API (PEP 489) and convert its static types to heap types.

  • bpo-37961: Fix crash in tracemalloc.Traceback.__repr__() (regressed in Python 3.9).

  • bpo-42630: tkinter functions and constructors which need a default root window raise now RuntimeError with descriptive message instead of obscure AttributeError or NameError if it is not created yet or cannot be created automatically.

  • bpo-42639: atexit._run_exitfuncs() now logs callback exceptions using sys.unraisablehook, rather than logging them directly into sys.stderr and raise the last exception.

  • bpo-42644: logging.disable will now validate the types and value of its parameter. It also now accepts strings representing the levels (as does loging.setLevel) instead of only the numerical values.

  • bpo-42639: At Python exit, if a callback registered with atexit.register() fails, its exception is now logged. Previously, only some exceptions were logged, and the last exception was always silently ignored.

  • bpo-36541: Fixed lib2to3.pgen2 to be able to parse PEP-570 positional only argument syntax.

  • bpo-42382: In importlib.metadata: - EntryPoint objects now expose a .dist object referencing the Distribution when constructed from a Distribution. - Add support for package discovery under package normalization rules. - The object returned by metadata() now has a formally-defined protocol called PackageMetadata with declared support for the .get_all() method. - Synced with importlib_metadata 3.3.

  • bpo-41877: A check is added against misspellings of autospect, auto_spec and set_spec being passed as arguments to patch, patch.object and create_autospec.

  • bpo-39717: [tarfile] update nested exception raising to use from None or from e

  • bpo-41877: AttributeError for suspected misspellings of assertions on mocks are now pointing out that the cause are misspelled assertions and also what to do if the misspelling is actually an intended attribute name. The unittest.mock document is also updated to reflect the current set of recognised misspellings.

  • bpo-41559: Implemented PEP 612: added ParamSpec and Concatenate to typing. Patch by Ken Jin.

  • bpo-42385: StrEnum: fix _generate_next_value_ to return a str

  • bpo-31904: Define THREAD_STACK_SIZE for VxWorks.

  • bpo-34750: [Enum] _EnumDict.update() is now supported

  • bpo-42517: Enum: private names do not become members / do not generate errors – they remain normal attributes

  • bpo-42678: Enum: call __init_subclass__ after members have been added

  • bpo-28964: ast.literal_eval() adds line number information (if available) in error message for malformed nodes.

  • bpo-42470: random.sample() no longer warns on a sequence which is also a set.

  • bpo-31904: posixpath.expanduser() returns the input path unchanged if user home directory is None on VxWorks.

  • bpo-42388: Fix subprocess.check_output(…, input=None) behavior when text=True to be consistent with that of the documentation and universal_newlines=True.

  • bpo-34463: Fixed discrepancy between traceback and the interpreter in formatting of SyntaxError with lineno not set (traceback was changed to match interpreter).

  • bpo-42393: Raise OverflowError instead of silent truncation in socket.ntohs() and socket.htons(). Silent truncation was deprecated in Python 3.7. Patch by Erlend E. Aasland

  • bpo-42222: Harmonized random.randrange() argument handling to match range().

    • The integer test and conversion in randrange() now uses operator.index().

    • Non-integer arguments to randrange() are deprecated.

    • The ValueError is deprecated in favor of a TypeError.

    • It now runs a little faster than before.

    (Contributed by Raymond Hettinger and Serhiy Storchaka.)

  • bpo-42163: Restore compatibility for uname_result around deepcopy and _replace.

  • bpo-42090: zipfile.Path.joinpath now accepts arbitrary arguments, same as pathlib.Path.joinpath.

  • bpo-1635741: Port the _csv module to the multi-phase initialization API (PEP 489).

  • bpo-42059: typing.TypedDict types created using the alternative call-style syntax now correctly respect the total keyword argument when setting their __required_keys__ and __optional_keys__ class attributes.

  • bpo-41960: Add globalns and localns parameters to the inspect.signature() and inspect.Signature.from_callable().

  • bpo-41907: fix format() behavior for IntFlag

  • bpo-41891: Ensure asyncio.wait_for waits for task completion

  • bpo-24792: Fixed bug where zipimporter sometimes reports an incorrect cause of import errors.

  • bpo-31904: Fix site and sysconfig modules for VxWorks RTOS which has no home directories.

  • bpo-41462: Add os.set_blocking() support for VxWorks RTOS.

  • bpo-40219: Lowered tkinter.ttk.LabeledScale dummy widget to prevent hiding part of the content label.

  • bpo-37193: Fixed memory leak in socketserver.ThreadingMixIn introduced in Python 3.7.

  • bpo-39068: Fix initialization race condition in a85encode() and b85encode() in base64. Patch by Brandon Stansbury.

Documentation

Tests

  • bpo-42794: Update test_nntplib to use offical group name of news.aioe.org for testing. Patch by Dong-hee Na.

  • bpo-31904: Skip some asyncio tests on VxWorks.

  • bpo-42641: Enhance test_select.test_select(): it now takes 500 ms rather than 10 seconds. Use Python rather than a shell to make the test more portable.

  • bpo-31904: Skip some tests in _test_all_chown_common() on VxWorks.

  • bpo-42199: Fix bytecode helper assertNotInBytecode.

  • bpo-41443: Add more attribute checking in test_posix.py

  • bpo-31904: Disable os.popen and impacted tests on VxWorks

  • bpo-41439: Port test_ssl and test_uuid to VxWorks RTOS.

Build

  • bpo-42692: Fix __builtin_available check on older compilers. Patch by Joshua Root.

  • bpo-27640: Added --disable-test-modules option to the configure script: don’t build nor install test modules. Patch by Xavier de Gaye, Thomas Petazzoni and Peixing Xin.

  • bpo-42604: Now all platforms use a value for the “EXT_SUFFIX” build variable derived from SOABI (for instance in freeBSD, “EXT_SUFFIX” is now “.cpython-310d.so” instead of “.so”). Previosuly only Linux, Mac and VxWorks were using a value for “EXT_SUFFIX” that included “SOABI”.

  • bpo-42598: Fix implicit function declarations in configure which could have resulted in incorrect configuration checks. Patch contributed by Joshua Root.

  • bpo-31904: Enable libpython3.so for VxWorks.

  • bpo-29076: Add fish shell support to macOS installer.

macOS

  • bpo-42361: Update macOS installer build to use Tcl/Tk 8.6.11 (rc2, expected to be final release).

  • bpo-41837: Update macOS installer build to use OpenSSL 1.1.1i.

  • bpo-42584: Update macOS installer to use SQLite 3.34.0.

Tools/Demos

  • bpo-42726: Fixed Python 3 compatibility issue with gdb/libpython.py handling of attribute dictionaries.

  • bpo-42613: Fix freeze.py tool to use the prope config and library directories. Patch by Victor Stinner.

C API

  • bpo-42591: Export the Py_FrozenMain() function: fix a Python 3.9.0 regression. Python 3.9 uses -fvisibility=hidden and the function was not exported explicitly and so not exported.

  • bpo-32381: Remove the private _Py_fopen() function which is no longer needed. Use _Py_wfopen() or _Py_fopen_obj() instead. Patch by Victor Stinner.

  • bpo-1635741: Port resource extension module to module state

  • bpo-42111: Update the xxlimited module to be a better example of how to use the limited C API.

  • bpo-40052: Fix an alignment build warning/error in function PyVectorcall_Function(). Patch by Andreas Schneider, Antoine Pitrou and Petr Viktorin.

Python 3.10.0 alpha 3

Release date: 2020-12-07

Security

  • bpo-40791: Add volatile to the accumulator variable in hmac.compare_digest, making constant-time-defeating optimizations less likely.

Core and Builtins

  • bpo-42576: types.GenericAlias will now raise a TypeError when attempting to initialize with a keyword argument. Previously, this would cause the interpreter to crash if the interpreter was compiled with debug symbols. This does not affect interpreters compiled for release. Patch by Ken Jin.

  • bpo-42536: Several built-in and standard library types now ensure that their internal result tuples are always tracked by the garbage collector:

    Previously, they could have become untracked by a prior garbage collection. Patch by Brandt Bucher.

  • bpo-42500: Improve handling of exceptions near recursion limit. Converts a number of Fatal Errors in RecursionErrors.

  • bpo-42246: PEP 626: After a return, the f_lineno attribute of a frame is always the last line executed.

  • bpo-42435: Speed up comparison of bytes objects with non-bytes objects when option -b is specified. Speed up comparison of bytarray objects with non-buffer object.

  • bpo-1635741: Port the _warnings extension module to the multi-phase initialization API (PEP 489). Patch by Victor Stinner.

  • bpo-41686: On Windows, the SIGINT event, _PyOS_SigintEvent(), is now created even if Python is configured to not install signal handlers (if PyConfig.install_signal_handlers equals to 0, or Py_InitializeEx(0)).

  • bpo-42381: Allow assignment expressions in set literals and set comprehensions as per PEP 572. Patch by Pablo Galindo.

  • bpo-42202: Change function parameters annotations internal representation to tuple of strings. Patch provided by Yurii Karabas.

  • bpo-42374: Fix a regression introduced by the new parser, where an unparenthesized walrus operator was not allowed within generator expressions.

  • bpo-42316: Allow an unparenthesized walrus in subscript indexes.

  • bpo-42349: Make sure that the compiler front-end produces a well-formed control flow graph. Be be more aggressive in the compiler back-end, as it is now safe to do so.

  • bpo-42296: On Windows, fix a regression in signal handling which prevented to interrupt a program using CTRL+C. The signal handler can be run in a thread different than the Python thread, in which case the test deciding if the thread can handle signals is wrong.

  • bpo-42332: types.GenericAlias objects can now be the targets of weakrefs.

  • bpo-42282: Optimise constant subexpressions that appear as part of named expressions (previously the AST optimiser did not descend into named expressions). Patch by Nick Coghlan.

  • bpo-42266: Fixed a bug with the LOAD_ATTR opcode cache that was not respecting monkey-patching a class-level attribute to make it a descriptor. Patch by Pablo Galindo.

  • bpo-40077: Convert queue to use heap types.

  • bpo-42246: Improved accuracy of line tracing events and f_lineno attribute of Frame objects. See PEP 626 for details.

  • bpo-40077: Convert mmap to use heap types.

  • bpo-42233: Allow GenericAlias objects to use union type expressions. This allows expressions like list[int] | dict[float, str] where previously a TypeError would have been thrown. This also fixes union type expressions not de-duplicating GenericAlias objects. (Contributed by Ken Jin in bpo-42233.)

  • bpo-26131: The import system triggers a ImportWarning when it falls back to using load_module().

Library

  • bpo-5054: CGIHTTPRequestHandler.run_cgi() HTTP_ACCEPT improperly parsed. Replace the special purpose getallmatchingheaders with generic get_all method and add relevant tests.

    Original Patch by Martin Panter. Modified by Senthil Kumaran.

  • bpo-42562: Fix issue when dis failed to parse function that has no line numbers. Patch provided by Yurii Karabas.

  • bpo-17735: inspect.findsource() now raises OSError instead of IndexError when co_lineno of a code object is greater than the file length. This can happen, for example, when a file is edited after it was imported. PR by Irit Katriel.

  • bpo-42116: Fix handling of trailing comments by inspect.getsource().

  • bpo-42532: Remove unexpected call of __bool__ when passing a spec_arg argument to a Mock.

  • bpo-38200: Added itertools.pairwise()

  • bpo-41818: Fix test_master_read() so that it succeeds on all platforms that either raise OSError or return b”” upon reading from master.

  • bpo-42487: ChainMap.__iter__ no longer calls __getitem__ on underlying maps

  • bpo-42482: TracebackException no longer holds a reference to the exception’s traceback object. Consequently, instances of TracebackException for equivalent but non-equal exceptions now compare as equal.

  • bpo-41818: Make test_openpty() avoid unexpected success due to number of rows and/or number of columns being == 0.

  • bpo-42392: Remove loop parameter from asyncio.subprocess and asyncio.tasks functions. Patch provided by Yurii Karabas.

  • bpo-42392: Remove loop parameter from asyncio.open_connection and asyncio.start_server functions. Patch provided by Yurii Karabas.

  • bpo-28468: Add platform.freedesktop_os_release() function to parse freedesktop.org os-release files.

  • bpo-42299: Removed the formatter module, which was deprecated in Python 3.4. It is somewhat obsolete, little used, and not tested. It was originally scheduled to be removed in Python 3.6, but such removals were delayed until after Python 2.7 EOL. Existing users should copy whatever classes they use into their code. Patch by Dong-hee Na and and Terry J. Reedy.

  • bpo-26131: Deprecate zipimport.zipimporter.load_module() in favour of exec_module().

  • bpo-41818: Updated tests for the pty library. test_basic() has been changed to test_openpty(); this additionally checks if slave termios and slave winsize are being set properly by pty.openpty(). In order to add support for FreeBSD, NetBSD, OpenBSD, and Darwin, this also adds test_master_read(), which demonstrates that pty.spawn() should not depend on an OSError to exit from its copy loop.

  • bpo-42392: Remove loop parameter from __init__ in all asyncio.locks and asyncio.Queue classes. Patch provided by Yurii Karabas.

  • bpo-15450: Make filecmp.dircmp respect subclassing. Now the filecmp.dircmp.subdirs behaves as expected when subclassing dircmp.

  • bpo-42413: The exception socket.timeout is now an alias of TimeoutError.

  • bpo-31904: Support signal module on VxWorks.

  • bpo-42406: We fixed an issue in pickle.whichmodule in which importing multiprocessing could change the how pickle identifies which module an object belongs to, potentially breaking the unpickling of those objects.

  • bpo-42403: Simplify the importlib external bootstrap code: importlib._bootstrap_external now uses regular imports to import builtin modules. When it is imported, the builtin __import__() function is already fully working and so can be used to import builtin modules like sys. Patch by Victor Stinner.

  • bpo-1635741: Convert _sre module types to heap types (PEP 384). Patch by Erlend E. Aasland.

  • bpo-42375: subprocess module update for DragonFlyBSD support.

  • bpo-41713: Port the _signal extension module to the multi-phase initialization API (PEP 489). Patch by Victor Stinner and Mohamed Koubaa.

  • bpo-37205: time.time(), time.perf_counter() and time.monotonic() functions can no longer fail with a Python fatal error, instead raise a regular Python exception on failure.

  • bpo-42328: Fixed tkinter.ttk.Style.map(). The function accepts now the representation of the default state as empty sequence (as returned by Style.map()). The structure of the result is now the same on all platform and does not depend on the value of wantobjects.

  • bpo-42345: Fix various issues with typing.Literal parameter handling (flatten, deduplicate, use type to cache key). Patch provided by Yurii Karabas.

  • bpo-37205: time.perf_counter() on Windows and time.monotonic() on macOS are now system-wide. Previously, they used an offset computed at startup to reduce the precision loss caused by the float type. Use time.perf_counter_ns() and time.monotonic_ns() added in Python 3.7 to avoid this precision loss.

  • bpo-42318: Fixed support of non-BMP characters in tkinter on macOS.

  • bpo-42350: Fix the threading.Thread class at fork: do nothing if the thread is already stopped (ex: fork called at Python exit). Previously, an error was logged in the child process.

  • bpo-42333: Port _ssl extension module to heap types.

  • bpo-42014: The onerror callback from shutil.rmtree now receives correct function when os.open fails.

  • bpo-42237: Fix os.sendfile() on illumos.

  • bpo-42308: Add threading.__excepthook__ to allow retrieving the original value of threading.excepthook() in case it is set to a broken or a different value. Patch by Mario Corchero.

  • bpo-42131: Implement PEP 451/spec methods on zipimport.zipimporter: find_spec(), create_module(), and exec_module().

    This also allows for the documented deprecation of find_loader(), find_module(), and load_module().

  • bpo-41877: Mock objects which are not unsafe will now raise an AttributeError if an attribute with the prefix asert, aseert, or assrt is accessed, in addition to this already happening for the prefixes assert or assret.

  • bpo-42264: sqlite3.OptimizedUnicode has been undocumented and obsolete since Python 3.3, when it was made an alias to str. It is now deprecated, scheduled for removal in Python 3.12.

  • bpo-42251: Added threading.gettrace() and threading.getprofile() to retrieve the functions set by threading.settrace() and threading.setprofile() respectively. Patch by Mario Corchero.

  • bpo-42249: Fixed writing binary Plist files larger than 4 GiB.

  • bpo-42236: On Unix, the os.device_encoding() function now returns 'UTF-8' rather than the device encoding if the Python UTF-8 Mode is enabled.

  • bpo-41754: webbrowser: Ignore NotADirectoryError when calling xdg-settings.

  • bpo-42183: Fix a stack overflow error for asyncio Task or Future repr().

    The overflow occurs under some circumstances when a Task or Future recursively returns itself.

  • bpo-42140: Improve asyncio.wait function to create the futures set just one time.

  • bpo-42133: Update various modules in the stdlib to fall back on __spec__.loader when __loader__ isn’t defined on a module.

  • bpo-26131: The load_module() methods found in importlib now trigger a DeprecationWarning.

  • bpo-39825: Windows: Change sysconfig.get_config_var('EXT_SUFFIX') to the expected full platform_tag.extension format. Previously it was hard-coded to .pyd, now it is compatible with distutils.sysconfig and will result in something like .cp38-win_amd64.pyd. This brings windows into conformance with the other platforms.

  • bpo-26389: The traceback.format_exception(), traceback.format_exception_only(), and traceback.print_exception() functions can now take an exception object as a positional-only argument.

  • bpo-41889: Enum: fix regression involving inheriting a multiply-inherited enum

  • bpo-41861: Convert sqlite3 to use heap types (PEP 384). Patch by Erlend E. Aasland.

  • bpo-40624: Added support for the XPath != operator in xml.etree

  • bpo-28850: Fix pprint.PrettyPrinter.format() overrides being ignored for contents of small containers. The pprint._safe_repr() function was removed.

  • bpo-41625: Expose the splice() as os.splice() in the os module. Patch by Pablo Galindo

  • bpo-34215: Clarify the error message for asyncio.IncompleteReadError when expected is None.

  • bpo-41543: Add async context manager support for contextlib.nullcontext.

  • bpo-21041: pathlib.PurePath.parents now supports negative indexing. Patch contributed by Yaroslav Pankovych.

  • bpo-41332: Added missing connect_accepted_socket() method to asyncio.AbstractEventLoop.

  • bpo-12800: Extracting a symlink from a tarball should succeed and overwrite the symlink if it already exists. The fix is to remove the existing file or symlink before extraction. Based on patch by Chris AtLee, Jeffrey Kintscher, and Senthil Kumaran.

  • bpo-40968: urllib.request and http.client now send http/1.1 ALPN extension during TLS handshake when no custom context is supplied.

  • bpo-41001: Add func:os.eventfd to provide a low level interface for Linux’s event notification file descriptor.

  • bpo-40816: Add AsyncContextDecorator to contextlib to support async context manager as a decorator.

  • bpo-40550: Fix time-of-check/time-of-action issue in subprocess.Popen.send_signal.

  • bpo-39411: Add an is_async identifier to pyclbr’s Function objects. Patch by Batuhan Taskaya

  • bpo-35498: Add slice support to pathlib.PurePath.parents.

Documentation

  • bpo-42238: Tentative to deprecate make suspicious by first removing it from the CI and documentation builds, but keeping it around for manual uses.

  • bpo-42153: Fix the URL for the IMAP protocol documents.

  • bpo-41028: Language and version switchers, previously maintained in every cpython branches, are now handled by docsbuild-script.

Tests

Build

  • bpo-31904: remove libnet dependency from detect_socket() for VxWorks

  • bpo-42398: Fix a race condition in “make regen-all” when make -jN option is used to