Changelog¶
Python 3.10.0 final¶
Release date: 2021-10-04
Core and Builtins¶
bpo-45121: Fix issue where
Protocol.__init__raisesRecursionErrorwhen it’s called directly or viasuper(). Patch provided by Yurii Karabas.
Library¶
bpo-45234: Fixed a regression in
copyfile(),copy(),copy2()raisingFileNotFoundErrorwhen source is a directory, which should raiseIsADirectoryError
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.abcdocumentation 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_forkfailure due totest_loggingandsys.modulesmanipulation.bpo-44860: Update
test_sysconfig.test_user_similar()for the posix_user scheme:platlibdoesn’t usesys.platlibdir. Patch by Victor Stinner.
Build¶
bpo-45067: The ncurses function extended_color_content was introduced in 2017
ncurses-devel package in CentOS 7 had a older version ncurses resulted in compilation error. For compiling ncurses with extended color support, we verify the version of the ncurses library >= 20170401.
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()withTemporaryDirectoryto 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
putcmdfunction insmtplibsanitize input for presence of\rand\ncharacters 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
SyntaxErroris now raised when trying to delete__debug__. Patch by Dong-hee Na.bpo-44963: Implement
send()andthrow()methods foranext_awaitableobjects. 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
floatorcomplex.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_SetObjecthangs 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
SyntaxErrorfor invalid ‘if’ expressions. Patch by Pablo Galindo.bpo-44584: The threading debug (
PYTHONTHREADDEBUGenvironment 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.Protocolsubclasses have wrong__init__. Patch provided by Yurii Karabas.bpo-41620:
run()now always return aTestResultinstance. Previously it returnedNoneif 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 definestearDownModule()in their test module.Functions registered with
addClassCleanup()were not called iftearDownClassis set toNone.Buffering in
TestResultdid not work with functions registered withaddClassCleanup()andaddModuleCleanup().Errors in functions registered with
addClassCleanup()andaddModuleCleanup()were not handled correctly in buffered and debug modes.Errors in
setUpModule()and functions registered withaddModuleCleanup()were reported in wrong order.And several lesser bugs.
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
faulthandlermodule: no longer modify the reference count of frame objects. Patch by Victor Stinner.bpo-44955: Method
stopTestRun()is now always called in pair with methodstartTestRun()forTestResultobjects implicitly created inrun(). Previously it was not called for test methods and classes decorated with a skipping decorator.bpo-44935:
subprocesson Solaris now also usesos.posix_spawn()for better performance.bpo-44911:
IsolatedAsyncioTestCasewill 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 withargparse.ArgumentDefaultsHelpFormatter.bpo-44860: Fix the
posix_userscheme insysconfigto not depend onsys.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 theO_PATHflag: ignore theEBADFerror onioctl(), fallback on thefcntl()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 beNone.bpo-44822:
sqlite3user-defined functions and aggregators returningstringswith embedded NUL characters are no longer truncated. Patch by Erlend E. Aasland.bpo-44801: Ensure that the
ParamSpecvariable in Callable can only be substituted with a parameters expression (a list of types, an ellipsis, ParamSpec or Concatenate).bpo-27334: The
sqlite3context 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 and7bitcontent 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 | Ymore prominently in section aboutUnionand mentionX | Noneat all in section aboutOptional.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:
base64RFC 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 htmlwhen 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
zipfiledocs: 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__.pyin 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_basicstest was ignored, becauseself.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
sizeofSharedMemoryis not ever guaranteed to be the same. It is decided by the platform.bpo-45042: Fixes that test classes decorated with
@hashlib_helper.requires_hashdigestwere skipped all the time.bpo-45011: Made tests relying on the
_asyncioC 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 whenobj * 1is used onstrandbytesobjects. 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_librarywas 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¶
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.Uniontotypes.UnionType.bpo-44698: Fix undefined behaviour in complex object exponentiation.
bpo-44653: Support
typingtypes in parameter substitution in the union type.bpo-44676: Add ability to serialise
types.Unionobjects. Patch provided by Yurii Karabas.bpo-44633: Parameter substitution of the union type with wrong types now raises
TypeErrorinstead of returningNotImplemented.bpo-44662: Add
__module__totypes.Union. This also fixestypes.Unionissues withtyping.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 | intis nowint. Fix comparison of the union type with non-hashable objects. E.g.int | str == {}no longer raises a TypeError.bpo-44635: Convert
Nonetotype(None)in the union type constructor.bpo-44589: Mapping patterns in
matchstatements with two or more equal literal keys will now raise aSyntaxErrorat compile-time.bpo-44606: Fix
__instancecheck__and__subclasscheck__for the union type.bpo-42073: The
@classmethoddecorator can now wrap other classmethod-like descriptors.bpo-44490:
typingnow searches for type parameters intypes.Unionobjects.get_type_hintswill also properly resolve annotations with nestedtypes.Unionobjects. Patch provided by Yurii Karabas.bpo-44490: Add
__parameters__attribute and__getitem__operator totypes.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.Protocolignore now the__init__method inherited from protocol base classes.bpo-44793: Fix checking the number of arguments when subscribe a generic type with
ParamSpecparameter.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 aNEWLINEtoken if the source doesn’t end with a new line character but the last line is a comment, as the function is already generating aNLtoken. Patch by Pablo Galindobpo-44752:
rcompleterdoes not callgetattr()onpropertyobjects to avoid the side-effect of evaluating the corresponding method.bpo-44720:
weakref.proxyobjects referencing non-iterators now raiseTypeErrorrather than dereferencing the nulltp_iternextslot and crashing.bpo-44704: The implementation of
collections.abc.Set._hash()now matches that offrozenset.__hash__().bpo-44666: Fixed issue in
compileall.compile_file()whensys.stdoutis redirected. Patch by Stefan Hölzl.bpo-42854: Fixed a bug in the
_sslmodule that was throwingOverflowErrorwhen using_ssl._SSLSocket.write()and_ssl._SSLSocket.read()for a big value of thelenparameter. Patch by Pablo Galindobpo-44353: Refactor
typing.NewTypefrom function into callable class. Patch provided by Yurii Karabas.bpo-44524: Add missing
__name__and__qualname__attributes totypingmodule 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 ofTypeError, it should beOSErrorwith 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 raiseFileNotFoundErrorinstead of confusingIsADirectoryErrorwhen a path ending with aos.path.sepdoes not exist;shutil.copy()andshutil.copy2()are also affected.bpo-44566: handle StopIteration subclass raised from @contextlib.contextmanager generator
bpo-41249: Fixes
TypedDictto work withtyping.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__modulebpo-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 acceptsemail.header.Headerobjects along with string values. Patch by Zackery Spytz.bpo-29298: Fix
TypeErrorwhen required subparsers withoutdestdo 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(), andtextwrap.shorten(). Now, there are nav links to attributes ofTextWrap, 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¶
bpo-44572: Avoid consuming standard input in the
platformmodulebpo-40263: This is a follow-on bug from https://bugs.python.org/issue26903. Once that is applied we run into an off-by-one assertion problem. The assert was not correct.
macOS¶
Tools/Demos¶
bpo-44756: In the Makefile for documentation (
Doc/Makefile), thebuildrule is dependent on thevenvrule. Therefore,html,latex, and other build-dependent rules are also now dependent onvenv. Thevenvrule only performs an action if$(VENVDIR)does not exist.Doc/README.rstwas updated; most users now only need to typemake 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_TAGtype flag now does nothing. ThePy_TPFLAGS_HAVE_AM_SENDflag (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
marshalmodule, and stop raisingcode.__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.pycfiles.
Core and Builtins¶
bpo-44562: Remove uses of
PyObject_GC_Del()in error path when initializingtypes.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.Unionto break reference cycles and prevent memory leaks.bpo-44523: Remove the pass-through for
hash()ofweakref.proxyobjects 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.Unionobjects 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.PrettyPrinterconstruction 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_MAPPINGandPy_TPFLAGS_SEQUENCEflags for subclasses created before a parent has been registered as acollections.abc.Mappingorcollections.abc.Sequence.bpo-44482: Fix very unlikely resource leak in
globin alternate Python implementations.bpo-44466: The
faulthandlermodule now detects if a fatal error occurs during a garbage collector collection. Patch by Victor Stinner.bpo-44404:
tkinter’safter()method now supports callables without the__name__attribute.bpo-44458:
BUFFER_BLOCK_SIZEis 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
linenomight beNoneintraceback.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()andtraceback.format_exception_only().bpo-30256: Pass multiprocessing BaseProxy argument
manager_ownedthrough 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.defaultdictparameterdefault_factorydefaults 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_TIMEOUTtimeout 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
DeprecationWarningfilters intest.test_importlib.test_metadata_api.APITests.test_entry_points_by_indexto avoidStopIterationerror ifDeprecationWarningsare ignored.bpo-30256: Add test for nested queues when using
multiprocessingshared objectsAutoProxy[Queue]insideListProxyandDictProxy
Build¶
Windows¶
bpo-44582: Accelerate speed of
mimetypesinitialization using a native implementation of the registry scan.bpo-41299: Fix 16ms jitter when using timeouts in
threading, such as withthreading.Lock.acquire()orthreading.Condition.wait().
C API¶
bpo-44441:
Py_RunMain()now resetsPyImport_Inittabto its initial value at exit. It must be possible to callPyImport_AppendInittab()orPyImport_ExtendInittab()at each Python initialization. Patch by Victor Stinner.bpo-40939: Removed documentation for the removed
PyParser_*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
sqlite3module that happened when the garbage collector clearssqlite.Statementobjects. Patch by Pablo Galindobpo-44305: Improve error message for
tryblocks withoutexceptorfinallyblocks. 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.ASTobjects with recursive references throughcompile(), the interpreter doesn’t crash anymore instead it raises aRecursionError.
Library¶
bpo-42972: The _thread.RLock type now fully implement the GC protocol: add a traverse function and the
Py_TPFLAGS_HAVE_GCflag. 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_3bpo-44362: Improve
sslmodule’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()indistutils.sysconfigbecause it behaves differently than the similar implementation insysconfig.bpo-44242: Remove missing flag check from Enum creation and move into a
verifydecorator.bpo-44246: In
importlib.metadata, restore compatibility in the result fromDistribution.entry_points(EntryPoints) to honor expectations in older implementations and issuing deprecation warnings for these cases: A.EntryPointsobjects are once again mutable, allowing forsort()and other list-based mutation operations. Avoid deprecation warnings by casting to a mutable sequence (e.g.list(dist.entry_points).sort()). B.EntryPointsresults 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
sqlite3user-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
pdbdoes not always echo cleared breakpoints.bpo-37022:
pdbnow displays exceptions fromrepr()with itspandppcommands.
Documentation¶
bpo-44392: Added a new section in the C API documentation for types used in type hinting. Documented
Py_GenericAliasandPy_GenericAliasType.bpo-38291: Mark
typing.ioandtyping.reas 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, sinceread()can raisessl.SSLEOFErroron 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
EnableControlFlowGuardset toguardto 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¶
bpo-43795: The list in Contents of Limited API now shows the public name
PyFrameObjectrather than_frame. The non-existing entry_nodeno longer appears in the list.bpo-44378:
Py_IS_TYPE()no longer usesPy_TYPE()to avoid a compiler warning: no longer castconst PyObject*toPyObject*. Patch by Victor Stinner.
Python 3.10.0 beta 2¶
Release date: 2021-05-31
Security¶
bpo-44022: mod:
http.clientnow avoids infinitely reading potential HTTP headers after a100 Continuestatus 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 functiontype_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
exceptis not the lastexceptare 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
.formatin 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_privatecheck 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:
hmaccomputations were not releasing the GIL while calling the OpenSSLHMAC_UpdateC API (a new feature in 3.9). This unintentionally prevented parallel computation as otherhashlibalgorithms support.bpo-37788: Fix a reference leak when a Thread object is never joined.
bpo-38908: Subclasses of
typing.Protocolwhich only have data variables declared will now raise aTypeErrorwhen checked withisinstanceunless they are decorated withruntime_checkable(). Previously, these checks passed silently. Patch provided by Yurii Karabas.bpo-44098:
typing.ParamSpecwill no longer be found in the__parameters__of mosttypinggenerics except in valid use locations specified by PEP 612. This prevents incorrect usage liketyping.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.Errorin 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
webbrowsermodule.bpo-36515: The
hashlibmodule 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, andPatterntotyping.__all__. Patch by Jelle Zijlstra.bpo-43972: When
http.server.SimpleHTTPRequestHandlersends a301 (Moved Permanently)for a directory path not ending with/, add aContent-Length: 0header. This improves the behavior for certain clients.bpo-28528: Fix a bug in
pdbwherecheckline()raisesAttributeErrorif it is called afterreset().bpo-43650: Fix
MemoryErrorinshutil.unpack_archive()which fails insideshutil._unpack_zipfile()on large files. Patch by Igor Bolshakov.bpo-41730:
DeprecationWarningis now raised when importingtkinter.tix, which has been deprecated in documentation since Python 3.6.
Documentation¶
bpo-42392: Document the deprecation and removal of the
loopparameter for many functions and classes inasyncio.bpo-44195: Corrected references to
TraversableResourcesin docs. There is noTraversableReader.bpo-41963: Document that
ConfigParserstrips 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
dataclassesdocumentation 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_NewTypeaccepts aPyStructSequence_Descwithdocfield set toNULL.bpo-35753: Fix crash in doctest when doctest parses modules that include unwrappable functions by skipping those functions.
Build¶
bpo-41282: Fix broken
make installthat caused standard library extension modules to be unnecessarily and incorrectly rebuilt during the install phase of cpython.
Windows¶
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 incasepatterns.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¶
bpo-43795: The undocumented function
Py_FrozenMain()is removed from the Limited API.bpo-43795:
PyCodec_Unregister()is now properly exported as a function in the Windows Stable ABI DLL.
Python 3.10.0 beta 1¶
Release date: 2021-05-03
Security¶
bpo-43434: Creating
sqlite3.Connectionobjects now also producessqlite3.connectandsqlite3.connect/handleauditing events. Previously these events were only produced bysqlite3.connect()calls. Patch by Erlend E. Aasland.bpo-43998: The
sslmodule 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.SSLContextdefaults 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_Newevent when called through the_xxsubinterpretersmodule.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(), andsqlite3.Connection.load_extension(). Patch by Erlend E. Aasland.bpo-43756: Add new audit event
glob.glob/2to incorporate the new root_dir and dir_fd arguments added toglob.glob()andglob.iglob().bpo-36384:
ipaddressmodule 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 functionsocket.inet_aton()treats leading zeros as octal notatation. glibc implementation of moderninet_pton()does not accept any leading zeros. For a while theipaddressmodule 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.clientmodule.
Core and Builtins¶
bpo-43977: Prevent classes being both a sequence and a mapping when pattern matching.
bpo-43977: Use
tp_flagson the class object to determine if the subject is a sequence or mapping when pattern matching. Avoids the need to importcollections.abcwhen pattern matching.bpo-43892: Restore proper validation of complex literal value patterns when parsing
matchblocks.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
_signalmodule 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
retypes immutable. Patch by Erlend E. Aasland.bpo-43908: Make the
array.arraytype 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.MatchAsandMatchOrare now defined as pattern nodes rather than as expression nodes. Patch by Nick Coghlan.bpo-42725: Usage of
await/yield/yield fromand 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:
SyntaxErrorexceptions 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 annotationsthe 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
IndentationErrorexceptions. Patch by Pablo Galindobpo-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
NameErrorraised by the interpreter,PyErr_Display()will offer suggestions of similar variable names in the function that the exception was raised from. Patch by Pablo Galindobpo-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.aliasnodes now include source location metadata attributes e.g. lineno, col_offset.bpo-43797: Improve
SyntaxErrorerror 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.RecursionErroris 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.netrcto 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
TypeErrorwhen non-member is used in a containment check; In 3.12TrueorFalsewill be returned instead, and containment will returnTrueif 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
turtlemodule 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 toDescription, allow for any field to be encoded with multiline values, remove continuation lines from multiline values, and add a.jsonproperty for easy access to the PEP 566 JSON-compatible form. Sync withimportlib_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:
urllibcan 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(), andinspect.from_function()now callinspect.get_annotations()to retrieve annotations. This meansinspect.signature()andinspect.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
sslmodule now usesSSL_read_exandSSL_write_exinternally. 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
_sslextension module to multiphase initialization.bpo-43880:
sslnow 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.GenericAliasobjects no longer includetyping.ParamSpecin__parameters__(with the exception ofcollections.abc.Callable‘sGenericAlias). This means previously invalid uses ofParamSpec(such aslist[P]) which worked in earlier versions of Python 3.10 alpha, will now raiseTypeErrorduring substitution.bpo-43867: The
multiprocessingServerclass now explicitly catchsSystemExitand closes the client connection in this case. It happens when theServer.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 tobz2.BZ2File,gzip.GzipFile, andlzma.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 asio.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
KeyErrorraised intyping.get_type_hints()due to synthetic modules that don’t appear insys.modules.bpo-43776: When
subprocess.Popenargs are provided as a string or aspathlib.Path, the Popen instance repr now shows the right thing.bpo-42248: [Enum] ensure exceptions raised in
_missing__are releasedbpo-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_COMPAT1.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=Trueor be the subject of acreate_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_EOFconstants (OpenSSL 3.0.0)bpo-43785: Improve
bz2.BZ2Fileperformance 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 ingzipandlzmahave 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
sslerror codes are now OpenSSL version-specific. Exceptions will now show correct reason and library codes. Themake_ssl_data.pyscript has been rewritten to use OpenSSL’s text file with error codes.bpo-43766: Implement PEP 647 in the
typingmodule by addingTypeGuard.bpo-25264:
os.path.realpath()now accepts a strict keyword-only argument. When set toTrue,OSErroris 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 fromentry_points()as deprecated.bpo-47383: The
P.argsandP.kwargsattributes oftyping.ParamSpecare now instances of the new classestyping.ParamSpecArgsandtyping.ParamSpecKwargs, which enables a more usefulrepr(). Patch by Jelle Zijlstra.bpo-43731: Add an
encodingparameterlogging.fileConfig().bpo-43712: Add
encodinganderrorsparameters tofileinput.input()andfileinput.FileInput.bpo-38659: A
simple_enumdecorator is added to theenummodule to convert a normal class into an Enum.test_simple_enumadded to test simple enums against a corresponding normal Enum. Standard library modules updated to usesimple_enum.bpo-43764: Fix an issue where
__match_args__generation could fail for somedataclasses.bpo-43752: Fix
sqlite3regression for zero-sized blobs with converters, whereb""was returned instead ofNone. The regression was introduced by GH-24723. Patch by Erlend E. Aasland.bpo-43655:
tkinterdialog windows are now recognized as dialogs by window managers on macOS and X Window.bpo-43723: The following
threadingmethods are now deprecated and should be replaced:currentThread=>threading.current_thread()activeCount=>threading.active_count()Condition.notifyAll=>threading.Condition.notify_all()Event.isSet=>threading.Event.is_set()Thread.setName=>threading.Thread.namethread.getName=>threading.Thread.nameThread.isDaemon=>threading.Thread.daemonThread.setDaemon=>threading.Thread.daemon
Patch by Jelle Zijlstra.
bpo-2135: Deprecate find_module() and find_loader() implementations in importlib and zipimport.
bpo-43534:
turtle.textinput()andturtle.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()whenlzma/bz2are unavailable. Patch by Anthony Sottile.bpo-42967: Allow
bytesseparatorargument inurllib.parse.parse_qsandurllib.parse.parse_qslwhen parsingstrquery strings. Previously, this raised aTypeError.bpo-43296: Improve
sqlite3error handling:sqlite3_value_blob()errors that setSQLITE_NOMEMnow raiseMemoryError. Patch by Erlend E. Aasland.bpo-43312: New functions
sysconfig.get_preferred_scheme()andsysconfig.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 nowunknown database <database name>instead ofSQL logic error. Patch by Erlend E. Aasland.bpo-41282: Install schemes in
distutils.command.installare now loaded fromsysconfig.bpo-41282:
distutils.sysconfighas been merged tosysconfig.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:
pprintnow has support fordataclasses.dataclass. Patch by Lewis Gaul.bpo-39950: Add
pathlib.Path.hardlink_to()method that supersedeslink_to(). The new method has the same argument order assymlink_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
slotsparameter todataclasses.dataclassdecorator 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 forasynciofunctions which implicitly create aFutureorTaskobjects if there is no running event loop and no explicit loop argument is passed:ensure_future(),wrap_future(),gather(),shield(),as_completed()and constructors ofFuture,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/zlibmodules, and add.readall()function to_compression.DecompressReaderclass. 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 andreplace(). 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 of1or0.bpo-39906:
pathlib.Path.stat()andchmod()now accept a follow_symlinks keyword-only argument for consistency with corresponding functions in theosmodule.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()andhome()now consistently raiseRuntimeErrorexception when a home directory cannot be resolved. Previously aKeyErrorexception 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_ptype: embedded null characters would cause aValueErrorto 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_MAPPINGandPy_TPFLAGS_SEQUENCEtype 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
ifclause 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 thanos.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.libregrtestnow 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 onthreading.excepthook(). Use--fail-env-changedoption 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¶
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 affectedos.path.exists()andos.path.isdir().bpo-26227: Fixed decoding of host names in
socket.gethostbyaddr()andsocket.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
WindowsConsoleIOerrors 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/usrother than/usr/local. Previously, anything under/Systemwas 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/Librarywere 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_AUTOINITon macOS. Patch by Erlend E. Aasland.bpo-43492: Update macOS installer to use SQLite 3.35.4.
bpo-42235:
Mac/BuildScript/build-installer.pywill now use “–enable-optimizations” and--with-ltowhen 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_INSTANTIATIONtype flag to disallow creating type instances. Patch by Victor Stinner.bpo-43774: Remove the now unused
PYMALLOC_DEBUGmacro. Debug hooks on memory allocators are now installed by default if Python is built in debug mode (ifPy_DEBUGmacro is defined). Moreover, they can now be used on Python build in release mode (ex: usingPYTHONMALLOC=debugenvironment 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 thegcmodule.bpo-43908: Introduce
Py_TPFLAGS_IMMUTABLETYPEflag for immutable type objects, and modifyPyType_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 bypython3.dllon Windows. Like any function that takesFILE*, 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 asx is yin Python. Add also thePy_IsNone(),Py_IsTrue(),Py_IsFalse()functions to test if an object is, respectively, theNonesingleton, theTruesingleton or theFalsesingleton. Patch by Victor Stinner.
Python 3.10.0 alpha 7¶
Release date: 2021-04-05
Security¶
bpo-42988: CVE-2021-3426: Remove the
getfilefeature of thepydocmodule 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:
ftplibno 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_addressattribute on theirftplib.FTPinstances toTrueto re-enable it.bpo-43439: Add audit hooks for
gc.get_objects(),gc.get_referrers()andgc.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.stderrwith 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
_hashopensslextension. 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 590vectorcallcalling convention. Patch by Dong-hee Na.bpo-42137: The import system now prefers using
__spec__forModuleType.__repr__overmodule_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
SyntaxErrorfor 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_CheckSignalstries to execute a non-Python signal handler.bpo-42128: Add
__match_args__tostructsequencebased classes. Patch by Pablo Galindo.bpo-43390: CPython now sets the
SA_ONSTACKflag inPyOS_setsigfor 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 andsigaltstack()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 590vectorcallcalling 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.ServerProxyno longer ignores query and fragment in the URL of the server.bpo-31956: The
index()method ofarray.arraynow has optional start and stop parameters.bpo-40066: Enum: adjust
repr()to show only enum and member name (not value, nor angle brackets) andstr()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.SSLContextdebug callback withssl.SSLContext.sni_callback().bpo-43571: It’s now possible to create MPTCP sockets with IPPROTO_MPTCP
bpo-43542:
image/heicandimage/heifwere added tomimetypes.bpo-40645: The
hmacmodule now uses OpenSSL’s HMAC implementation when digestmod argument is a hash name or builtin hash function.bpo-43510: Implement PEP 597: Add
EncodingWarningwarning,-X warn_default_encodingoption,PYTHONWARNDEFAULTENCODINGenvironment variable andencoding="locale"argument value.bpo-43521:
ast.unparsecan now render NaNs and empty sets.bpo-42914:
pprint.pprint()gains a new booleanunderscore_numbersoptional argument to emit integers with thousands separated by an underscore character for improved readability (for example1_000_000instead of1000000).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 multiplecleanup()attempts. Contributed by C.A.M. Gerlach.bpo-43428: Include changes from importlib_metadata 3.7:
Performance enhancements to distribution discovery.
entry_pointsonly returns unique distributions.Introduces new
EntryPointsobject for containing a set of entry points with convenience methods for selecting entry points by group or name.entry_pointsnow 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.clientwhen using a proxy viaset_tunnel(). Fewer small send calls are made during connection setup.bpo-43420: Improve performance of
fractions.Fractionarithmetics for large components. Contributed by Sergey B. Kirpichev.bpo-43356: Allow passing a signal number to
_thread.interrupt_main().bpo-43399: Fix
ElementTree.extendnot working on iterators when using the Python implementationbpo-43369: Improve
sqlite3error handling: Ifsqlite3_column_text()andsqlite3_column_blob()setSQLITE_NOMEM,MemoryErroris now raised. Patch by Erlend E. Aasland.bpo-43368: Fix a regression introduced in GH-24562, where an empty bytestring was fetched as
Noneinstead ofb''insqlite3. Patch by Mariusz Felisiak.bpo-41282: Fixed stacklevel of
DeprecationWarningemitted fromimport distutils.bpo-42129:
importlib.resourcesnow honors namespace packages, merging resources from each location in the namespace as introduced inimportlib_resources3.2 and including incidental changes through 5.0.3.bpo-43295:
datetime.datetime.strptime()now raisesValueErrorinstead ofIndexErrorwhen matching'z'with the%zformat specifier.bpo-43125: Return empty string if base64mime.body_encode receive empty bytes
bpo-43084:
curses.window.enclose()returns nowTrueorFalse(as was documented) instead of1or0.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()andstr()have changed:repr()is now EnumClass.MemberName andstr()is MemberName. Additionally, stdlib Enum’s whose contents are available as module attributes, such asRegexFlag.IGNORECASE, have theirrepr()as module.name, e.g.re.IGNORECASE.bpo-26053: Fixed bug where the
pdbinteractive 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.tempdirglobal 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 thetempfile.gettempdir()andtempfile.gettempdirb()functions always returnstrandbytesrespectively.bpo-39342: Expose
X509_V_FLAG_ALLOW_PROXY_CERTSasVERIFY_ALLOW_PROXY_CERTSto 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¶
bpo-43199: Answer “Why is there no goto?” in the Design and History FAQ.
bpo-43407: Clarified that a result from
time.monotonic(),time.perf_counter(),time.process_time(), ortime.thread_time()can be compared with the result from any following call to the same function - not just the next immediate call.bpo-43354: Fix type documentation for
Fault.faultCode; the type has to beintinstead ofstr.bpo-41933: Clarified wording of s * n in the Common Sequence Operations
Tests¶
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
configurescript now supports--with-openssl-rpathoption.bpo-43372: Use
_freeze_importlibto 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¶
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_DEBUGmacro is defined). In the limited C API, thePy_INCREF()andPy_DECREF()functions are now implemented as opaque function calls, rather than accessing directly thePyObject.ob_refcntmember, if Python is built in debug mode and thePy_LIMITED_APImacro targets Python 3.10 or newer. It became possible to support the limited C API in debug mode because thePyObjectstructure 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-refsspecial build (Py_TRACE_REFSmacro).Patch by Victor Stinner.
bpo-43244: Remove the
pyarena.hheader 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 _modtype, 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, andPython-ast.hheader files. These functions were undocumented and excluded from the limited C API. Most names defined by these header files were not prefixed byPyand so could create names conflicts. For example,Python-ast.hdefined aYieldmacro which was conflict with theYieldname used by the Windows<winbase.h>header. Use the Pythonastmodule 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.hheader 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 thesymtable.hheader file was excluded from the limited C API.The Python
symtablemodule 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_tytype) 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
SystemErrorraised whenPyArg_Parse*()is used with#but withoutPY_SSIZE_T_CLEANdefined.bpo-36346:
PyArg_Parse*()functions now emitsDeprecationWarningwhenuorZformat 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 ofsetbut not an instance of a subtype. Patch by Pablo Galindo.bpo-42990: The
types.FunctionTypeconstructor now inherits the current builtins if the globals dictionary has no"__builtins__"key, rather than using{"None": None}as builtins: same behavior aseval()andexec()functions. Defining a function withdef 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
SyntaxErrormessage 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 callsreadline.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 callingreadline.parse_and_bind("set enable-bracketed-paste on"). Patch by Dustin Rodrigues.bpo-42808: Simple calls to
type(object)are now faster due to thevectorcallcalling 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 str2andstr2.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 thatmultiprocess.synchronize()is available on a given platform and rely on that check in theconcurrent.futurestest suite so we can run tests that are unrelated toProcessPoolExecutoron those platforms.bpo-38302: If
object.__ipow__()returnsNotImplemented, the operator will correctly fall back toobject.__pow__()andobject.__rpow__()as expected.
Library¶
bpo-43316: The
python -m gzipcommand 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
gzipmodule 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()andformat_exception().bpo-43260: Fix TextIOWrapper can not flush internal buffer forever after very large text is written.
bpo-43258: Prevent needless allocation of
sqlite3aggregate function context when no rows match an aggregate query. Patch by Erlend E. Aasland.bpo-43251: Improve
sqlite3error handling:sqlite3_column_name()failures now result inMemoryError. 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()andreadline.get_endidx()behavior based on libreadline vs libedit use.bpo-43163: Fix a bug in
codeopthat was causing it to not ask for more input when multi-line snippets have unclosed parentheses. Patch by Pablo Galindobpo-43162: deprecate unsupported ability to access enum members as attributes of other enum members
bpo-43146: Fix recent regression in None argument handling in
tracebackmodule 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_SYMLINKandO_NOFOLLOW_ANYfor macOS. Patch by Dong-hee Na.bpo-42960: Adds
resource.RLIMIT_KQUEUESconstant from FreeBSD to theresourcemodule.bpo-42151: Make the pure Python implementation of
xml.etree.ElementTreebehave the same as the C implementation (_elementree) regarding default attribute values (by not settingspecified_attributes=1).bpo-29753: In ctypes, now packed bitfields are calculated properly and the first item of packed bitfields is now shrank correctly.
Documentation¶
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-8compiler option.bpo-43103: Add a new configure
--without-static-libpythonoption to not build thelibpythonMAJOR.MINOR.astatic library and not install thepython.oobject 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 inpython3.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 publicPyErr_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 accessedPyTypeObject.tp_namedirectly. 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 accessedPyTypeObject.tp_iternextdirectly. Patch by Erlend E. Aasland.bpo-40170: Convert
PyDescr_IsData()macro to a function to hide implementation details: The macro accessedPyTypeObject.tp_descr_setdirectly. 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¶
bpo-42938: Avoid static buffers when computing the repr of
ctypes.c_doubleandctypes.c_longdoublevalues.
Core and Builtins¶
bpo-42990: Refactor the
PyEval_family of functions.An new function
_PyEval_Vectoris added to simplify calls to Python from C._PyEval_EvalCodeWithNameis removedPyEval_EvalCodeExis retained as part of the API, but is not used internally
bpo-38631: Replace
Py_FatalError()calls in the compiler with regularSystemErrorexceptions. 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_ATTRnow 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
bytearrayrepetition 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 thebytearrayto a shorter byte string).bpo-42882: Fix the
_PyUnicode_FromId()function (_Py_IDENTIFIER(var) API) whenPy_Initialize()/Py_Finalize()is called multiple times: preserve_PyRuntime.unicode_ids.next_indexvalue.bpo-42827: Fix a crash when working out the error line of a
SyntaxErrorin 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
collectionsmodule.bpo-41994: Fixed possible leak in
importwhensys.modulesis not adict.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
cursesmodule. Patch by Pablo Galindobpo-43077: Update the bundled pip to 21.0.1 and setuptools to 52.0.0.
bpo-41282: Deprecate
distutilsin documentation and add warning on import.bpo-43014: Improve performance of
tokenizeby 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.samplewhencountsargument is notNone.bpo-42934: Use
TracebackException’s newcompactparam inTestResultto reduce time and memory consumed by traceback formatting.bpo-42931: Add
randbytes()torandom.__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
compactparameter to the constructor oftraceback.TracebackExceptionto reduce time and memory for use cases that only need to callTracebackException.format()andTracebackException.format_exception_only().bpo-42923: The
Py_FatalError()function and thefaulthandlermodule now dump the list of extension modules on a fatal error.bpo-42848: Removed recursion from
TracebackExceptionto 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
_jsonmodule 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_wininstcommand deprecated in Python 3.8 has been removed. The distutilsbdist_wheelcommand is now recommended to distribute binary packages on Windows.bpo-24464: The undocumented built-in function
sqlite3.enable_shared_cacheis 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
cProfileandprofileto catchBrokenPipeError.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
Falsewhen passed toThreading.threadas 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 thecursesmodule if available.bpo-33289: Correct call to
tkinter.colorchooserto return RGB triplet of ints instead of floats. Patch by Cheryl Sabella.
Documentation¶
Tests¶
Build¶
bpo-43031: Pass
--timeout=$(TESTTIMEOUT)option to the default profile task./python -m test --pgocommand.bpo-36143:
make regen-allnow also runsregen-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=PATHoption to the./configurescript. If specified, theensurepipmodule looks forsetuptoolsandpipwheel 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 theensurepip._bundledpackage.
Windows¶
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 signedwchar_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
astnodes 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_lastiandf_linenoattributes 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-ccommand 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
atexitmodule state per-interpreter. It is now safe have more than oneatexitmodule instance. Patch by Dong-hee Na and Victor Stinner.bpo-32381: Fix encoding name when running a
.pycfile on Windows:PyRun_SimpleFileExFlags()now uses the correct encoding to decode the filename.bpo-42195: The
__args__of the parameterized generics fortyping.Callableandcollections.abc.Callableare now consistent. The__args__forcollections.abc.Callableare now flattened whiletyping.Callable’s have not changed. To allow this change,types.GenericAliascan now be subclassed andcollections.abc.Callable’s__class_getitem__will now return a subclass oftypes.GenericAlias. Tests for typing were also updated to not subclass things likeCallable[..., T]as that is not a valid base class. Finally, bothCallables no longer validate theirargtypes, inCallable[[argtypes], resulttype]to prepare for PEP 612. Patch by Ken Jin.bpo-40137: Convert functools module to use
PyType_FromModuleAndSpec().bpo-40077: Convert
arrayto use heap types, and establish module state for these.bpo-42008: Fix _random.Random() seeding.
bpo-1635741: Port the
pyexpatextension 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.Variableandtkinter.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()andtyping.get_origin()now support PEP 604 union types and PEP 612 additions toCallable.bpo-42655:
subprocessextra_groups is now correctly passed into setgroups() system call.bpo-42727:
EnumMeta.__prepare__now accepts**kwdsto 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, andNoDefaultRoot()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:
tkintersupports 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
_threadextension 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:
tkinterfunctions and constructors which need a default root window raise nowRuntimeErrorwith descriptive message instead of obscureAttributeErrororNameErrorif it is not created yet or cannot be created automatically.bpo-42639:
atexit._run_exitfuncs()now logs callback exceptions usingsys.unraisablehook, rather than logging them directly intosys.stderrand raise the last exception.bpo-42644:
logging.disablewill now validate the types and value of its parameter. It also now accepts strings representing the levels (as doesloging.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: -EntryPointobjects now expose a.distobject referencing theDistributionwhen constructed from aDistribution. - Add support for package discovery under package normalization rules. - The object returned bymetadata()now has a formally-defined protocol calledPackageMetadatawith 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 Noneorfrom ebpo-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
ParamSpecandConcatenatetotyping. 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 supportedbpo-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 addedbpo-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
tracebackand the interpreter in formatting of SyntaxError with lineno not set (tracebackwas changed to match interpreter).bpo-42393: Raise
OverflowErrorinstead of silent truncation insocket.ntohs()andsocket.htons(). Silent truncation was deprecated in Python 3.7. Patch by Erlend E. Aaslandbpo-42222: Harmonized
random.randrange()argument handling to matchrange().The integer test and conversion in
randrange()now usesoperator.index().Non-integer arguments to
randrange()are deprecated.The
ValueErroris deprecated in favor of aTypeError.It now runs a little faster than before.
(Contributed by Raymond Hettinger and Serhiy Storchaka.)
bpo-42163: Restore compatibility for
uname_resultaround deepcopy and _replace.bpo-42090:
zipfile.Path.joinpathnow accepts arbitrary arguments, same aspathlib.Path.joinpath.bpo-1635741: Port the _csv module to the multi-phase initialization API (PEP 489).
bpo-42059:
typing.TypedDicttypes created using the alternative call-style syntax now correctly respect thetotalkeyword argument when setting their__required_keys__and__optional_keys__class attributes.bpo-41960: Add
globalnsandlocalnsparameters to theinspect.signature()andinspect.Signature.from_callable().bpo-41907: fix
format()behavior forIntFlagbpo-41891: Ensure asyncio.wait_for waits for task completion
bpo-24792: Fixed bug where
zipimportersometimes 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.LabeledScaledummy widget to prevent hiding part of the content label.bpo-37193: Fixed memory leak in
socketserver.ThreadingMixInintroduced in Python 3.7.bpo-39068: Fix initialization race condition in
a85encode()andb85encode()inbase64. Patch by Brandon Stansbury.
Documentation¶
bpo-17140: Add documentation for the
multiprocessing.pool.ThreadPoolclass.bpo-34398: Prominently feature listings from the glossary in documentation search results. Patch by Ammar Askar.
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-modulesoption to theconfigurescript: 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¶
Tools/Demos¶
C API¶
bpo-42591: Export the
Py_FrozenMain()function: fix a Python 3.9.0 regression. Python 3.9 uses-fvisibility=hiddenand 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
resourceextension module to module statebpo-42111: Update the
xxlimitedmodule 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
volatileto the accumulator variable inhmac.compare_digest, making constant-time-defeating optimizations less likely.
Core and Builtins¶
bpo-42576:
types.GenericAliaswill now raise aTypeErrorwhen 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
-bis specified. Speed up comparison of bytarray objects with non-buffer object.bpo-1635741: Port the
_warningsextension module to the multi-phase initialization API (PEP 489). Patch by Victor Stinner.bpo-41686: On Windows, the
SIGINTevent,_PyOS_SigintEvent(), is now created even if Python is configured to not install signal handlers (ifPyConfig.install_signal_handlersequals to 0, orPy_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.GenericAliasobjects 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-42246: Improved accuracy of line tracing events and f_lineno attribute of Frame objects. See PEP 626 for details.
bpo-42233: Allow
GenericAliasobjects to use union type expressions. This allows expressions likelist[int] | dict[float, str]where previously aTypeErrorwould have been thrown. This also fixes union type expressions not de-duplicatingGenericAliasobjects. (Contributed by Ken Jin in bpo-42233.)bpo-26131: The import system triggers a
ImportWarningwhen it falls back to usingload_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 raisesOSErrorinstead ofIndexErrorwhenco_linenoof 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 aspec_argargument 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:
TracebackExceptionno 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.subprocessandasyncio.tasksfunctions. Patch provided by Yurii Karabas.bpo-42392: Remove loop parameter from
asyncio.open_connectionandasyncio.start_serverfunctions. Patch provided by Yurii Karabas.bpo-28468: Add
platform.freedesktop_os_release()function to parse freedesktop.orgos-releasefiles.bpo-42299: Removed the
formattermodule, 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 allasyncio.locksandasyncio.Queueclasses. Patch provided by Yurii Karabas.bpo-15450: Make
filecmp.dircmprespect subclassing. Now thefilecmp.dircmp.subdirsbehaves as expected when subclassing dircmp.bpo-42413: The exception
socket.timeoutis now an alias ofTimeoutError.bpo-31904: Support signal module on VxWorks.
bpo-42406: We fixed an issue in
pickle.whichmodulein which importingmultiprocessingcould change the how pickle identifies which module an object belongs to, potentially breaking the unpickling of those objects.bpo-42403: Simplify the
importlibexternal bootstrap code:importlib._bootstrap_externalnow 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 likesys. 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
_signalextension module to the multi-phase initialization API (PEP 489). Patch by Victor Stinner and Mohamed Koubaa.bpo-37205:
time.time(),time.perf_counter()andtime.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 byStyle.map()). The structure of the result is now the same on all platform and does not depend on the value ofwantobjects.bpo-42345: Fix various issues with
typing.Literalparameter handling (flatten, deduplicate, use type to cache key). Patch provided by Yurii Karabas.bpo-37205:
time.perf_counter()on Windows andtime.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. Usetime.perf_counter_ns()andtime.monotonic_ns()added in Python 3.7 to avoid this precision loss.bpo-42318: Fixed support of non-BMP characters in
tkinteron macOS.bpo-42350: Fix the
threading.Threadclass 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
onerrorcallback fromshutil.rmtreenow receives correct function whenos.openfails.bpo-42237: Fix
os.sendfile()on illumos.bpo-42308: Add
threading.__excepthook__to allow retrieving the original value ofthreading.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.OptimizedUnicodehas been undocumented and obsolete since Python 3.3, when it was made an alias tostr. It is now deprecated, scheduled for removal in Python 3.12.bpo-42251: Added
threading.gettrace()andthreading.getprofile()to retrieve the functions set bythreading.settrace()andthreading.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__.loaderwhen__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 fullplatform_tag.extensionformat. Previously it was hard-coded to.pyd, now it is compatible withdistutils.sysconfigand 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(), andtraceback.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
sqlite3to use heap types (PEP 384). Patch by Erlend E. Aasland.bpo-40624: Added support for the XPath
!=operator in xml.etreebpo-28850: Fix
pprint.PrettyPrinter.format()overrides being ignored for contents of small containers. Thepprint._safe_repr()function was removed.bpo-41625: Expose the
splice()asos.splice()in theosmodule. Patch by Pablo Galindobpo-34215: Clarify the error message for
asyncio.IncompleteReadErrorwhenexpectedisNone.bpo-41543: Add async context manager support for contextlib.nullcontext.
bpo-21041:
pathlib.PurePath.parentsnow 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.requestandhttp.clientnow sendhttp/1.1ALPN extension during TLS handshake when no custom context is supplied.bpo-41001: Add func:
os.eventfdto 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_asyncidentifier topyclbr’sFunctionobjects. Patch by Batuhan Taskayabpo-35498: Add slice support to
pathlib.PurePath.parents.
Documentation¶
bpo-42238: Tentative to deprecate
make suspiciousby 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¶
bpo-41473: Reenable test_gdb on gdb 9.2 and newer: https://bugzilla.redhat.com/show_bug.cgi?id=1866884 bug is fixed in gdb 10.1.
bpo-42553: Fix
test_asyncio.test_call_later()race condition: don’t measure asyncio performance in thecall_later()unit test. The test failed randomly on the CI.bpo-31904: Fix test_netrc on VxWorks: create temporary directories using temp_cwd().
bpo-31904: skip test_getaddrinfo_ipv6_scopeid_symbolic and test_getnameinfo_ipv6_scopeid_symbolic on VxWorks
bpo-31904: skip test_test of test_mailcap on VxWorks
bpo-31904: add shell requirement for test_pipes
bpo-31904: skip some tests related to fifo on VxWorks
bpo-31904: Fix test_doctest.py failures for VxWorks.
bpo-40754: Include
_testinternalcapimodule in Windows installer for test suitebpo-41561: test_ssl: skip test_min_max_version_mismatch when TLS 1.0 is not available
bpo-31904: Fix os module failures for VxWorks RTOS.
bpo-31904: Fix fifo test cases for VxWorks RTOS.