.. bpo: 42278
.. date: 2021-08-29-12-39-44
.. nonce: jvmQz_
.. release date: 2021-08-30
.. section: Security

Replaced usage of :func:`tempfile.mktemp` with
:class:`~tempfile.TemporaryDirectory` to avoid a potential race condition.

..

.. bpo: 41180
.. date: 2021-06-29-23-40-22
.. nonce: uTWHv_
.. section: Security

Add auditing events to the :mod:`marshal` module, and stop raising
``code.__init__`` events for every unmarshalled code object. Directly
instantiated code objects will continue to raise an event, and audit event
handlers should inspect or collect the raw marshal data. This reduces a
significant performance overhead when loading from ``.pyc`` files.

..

.. bpo: 44394
.. date: 2021-06-29-02-45-53
.. nonce: A220N1
.. section: Security

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
.. date: 2021-05-08-11-50-46
.. nonce: 2CTM6M
.. section: Security

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

..

.. bpo: 45018
.. date: 2021-08-26-18-44-03
.. nonce: pu8H9L
.. section: Core and Builtins

Fixed pickling of range iterators that iterated for over 2**32 times.

..

.. bpo: 44962
.. date: 2021-08-23-19-55-08
.. nonce: J00ftt
.. section: Core and Builtins

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
.. date: 2021-08-19-14-43-24
.. nonce: dLn3lg
.. section: Core and Builtins

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

..

.. bpo: 44947
.. date: 2021-08-18-19-09-28
.. nonce: mcvGdS
.. section: Core and Builtins

Refine the syntax error for trailing commas in import statements. Patch by
Pablo Galindo.

..

.. bpo: 44698
.. date: 2021-08-15-10-39-06
.. nonce: lITKNc
.. section: Core and Builtins

Restore behaviour of complex exponentiation with integer-valued exponent of
type :class:`float` or :class:`complex`.

..

.. bpo: 44885
.. date: 2021-08-11-15-39-57
.. nonce: i4noUO
.. section: Core and Builtins

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

..

.. bpo: 44872
.. date: 2021-08-09-16-16-03
.. nonce: OKRlhK
.. section: Core and Builtins

Use new trashcan macros (Py_TRASHCAN_BEGIN/END) in frameobject.c instead of
the old ones (Py_TRASHCAN_SAFE_BEGIN/END).

..

.. bpo: 33930
.. date: 2021-08-09-14-29-52
.. nonce: --5LQ-
.. section: Core and Builtins

Fix segmentation fault with deep recursion when cleaning method objects.
Patch by Augusto Goulart and Pablo Galindo.

..

.. bpo: 25782
.. date: 2021-08-07-21-39-19
.. nonce: B22lMx
.. section: Core and Builtins

Fix bug where ``PyErr_SetObject`` hangs when the current exception has a
cycle in its context chain.

..

.. bpo: 44856
.. date: 2021-08-07-01-26-12
.. nonce: 9rk3li
.. section: Core and Builtins

Fix reference leaks in the error paths of ``update_bases()`` and
``__build_class__``. Patch by Pablo Galindo.

..

.. bpo: 44698
.. date: 2021-07-21-15-26-56
.. nonce: DA4_0o
.. section: Core and Builtins

Fix undefined behaviour in complex object exponentiation.

..

.. bpo: 44562
.. date: 2021-07-04-23-38-51
.. nonce: QdeRQo
.. section: Core and Builtins

Remove uses of :c:func:`PyObject_GC_Del` in error path when initializing
:class:`types.GenericAlias`.

..

.. bpo: 44523
.. date: 2021-06-29-11-49-29
.. nonce: 67-ZIP
.. section: Core and Builtins

Remove the pass-through for :func:`hash` of :class:`weakref.proxy` objects
to prevent unintended consequences when the original referred object dies
while the proxy is part of a hashable object. Patch by Pablo Galindo.

..

.. bpo: 44472
.. date: 2021-06-21-11-19-54
.. nonce: Vvm1yn
.. section: Core and Builtins

Fix ltrace functionality when exceptions are raised. Patch by Pablo Galindo

..

.. bpo: 44184
.. date: 2021-05-21-01-42-45
.. nonce: 9qOptC
.. section: Core and Builtins

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

..

.. bpo: 39091
.. date: 2019-12-21-14-18-32
.. nonce: dOexgQ
.. section: Core and Builtins

Fix crash when using passing a non-exception to a generator's ``throw()``
method. Patch by Noah Oxer

..

.. bpo: 41620
.. date: 2021-08-29-14-49-22
.. nonce: WJ6PFL
.. section: Library

:meth:`~unittest.TestCase.run` now always return a
:class:`~unittest.TestResult` instance. Previously it returned ``None`` if
the test class or method was decorated with a skipping decorator.

..

.. bpo: 43913
.. date: 2021-08-27-23-40-51
.. nonce: Uo1Gt5
.. section: Library

Fix bugs in cleaning up classes and modules in :mod:`unittest`:

* Functions registered with :func:`~unittest.addModuleCleanup` were not called unless the user defines ``tearDownModule()`` in their test module.
* Functions registered with :meth:`~unittest.TestCase.addClassCleanup` were not called if ``tearDownClass`` is set to ``None``.
* Buffering in :class:`~unittest.TestResult` did not work with functions registered with ``addClassCleanup()`` and ``addModuleCleanup()``.
* Errors in functions registered with ``addClassCleanup()`` and ``addModuleCleanup()`` were not handled correctly in buffered and debug modes.
* Errors in ``setUpModule()`` and functions registered with ``addModuleCleanup()`` were reported in wrong order.
* And several lesser bugs.

..

.. bpo: 45001
.. date: 2021-08-26-16-25-48
.. nonce: tn_dKp
.. section: Library

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

..

.. bpo: 44449
.. date: 2021-08-20-11-30-52
.. nonce: 1r2-lS
.. section: Library

Fix a crash in the signal handler of the :mod:`faulthandler` module: no
longer modify the reference count of frame objects. Patch by Victor Stinner.

..

.. bpo: 44955
.. date: 2021-08-19-15-03-54
.. nonce: 1mxFQS
.. section: Library

Method :meth:`~unittest.TestResult.stopTestRun` is now always called in pair
with method :meth:`~unittest.TestResult.startTestRun` for
:class:`~unittest.TestResult` objects implicitly created in
:meth:`~unittest.TestCase.run`. Previously it was not called for test
methods and classes decorated with a skipping decorator.

..

.. bpo: 38956
.. date: 2021-08-09-13-17-10
.. nonce: owWLNv
.. section: Library

:class:`argparse.BooleanOptionalAction`'s default value is no longer printed
twice when used with :class:`argparse.ArgumentDefaultsHelpFormatter`.

..

.. bpo: 44581
.. date: 2021-08-06-19-15-52
.. nonce: oFDBTB
.. section: Library

Upgrade bundled pip to 21.2.3 and setuptools to 57.4.0

..

.. bpo: 44849
.. date: 2021-08-06-13-00-28
.. nonce: O78F_f
.. section: Library

Fix the :func:`os.set_inheritable` function on FreeBSD 14 for file
descriptor opened with the :data:`~os.O_PATH` flag: ignore the
:data:`~errno.EBADF` error on ``ioctl()``, fallback on the ``fcntl()``
implementation. Patch by Victor Stinner.

..

.. bpo: 44605
.. date: 2021-08-06-09-43-50
.. nonce: q4YSBZ
.. section: Library

The @functools.total_ordering() decorator now works with metaclasses.

..

.. bpo: 44822
.. date: 2021-08-04-12-29-00
.. nonce: zePNXA
.. section: Library

:mod:`sqlite3` user-defined functions and aggregators returning
:class:`strings <str>` with embedded NUL characters are no longer truncated.
Patch by Erlend E. Aasland.

..

.. bpo: 44815
.. date: 2021-08-03-15-02-28
.. nonce: 9AmFfy
.. section: Library

Always show ``loop=`` arg deprecations in :func:`asyncio.gather` and
:func:`asyncio.sleep`

..

.. bpo: 44806
.. date: 2021-08-02-14-37-32
.. nonce: wOW_Qn
.. section: Library

Non-protocol subclasses of :class:`typing.Protocol` ignore now the
``__init__`` method inherited from protocol base classes.

..

.. bpo: 44667
.. date: 2021-07-30-23-27-30
.. nonce: tu0Xrv
.. section: Library

The :func:`tokenize.tokenize` doesn't incorrectly generate a ``NEWLINE``
token if the source doesn't end with a new line character but the last line
is a comment, as the function is already generating a ``NL`` token. Patch by
Pablo Galindo

..

.. bpo: 42853
.. date: 2021-07-28-15-50-59
.. nonce: 8SYiF_
.. section: Library

Fix ``http.client.HTTPSConnection`` fails to download >2GiB data.

..

.. bpo: 44752
.. date: 2021-07-27-22-11-29
.. nonce: _bvbrZ
.. section: Library

:mod:`rcompleter` does not call :func:`getattr` on :class:`property` objects
to avoid the side-effect of  evaluating the corresponding method.

..

.. bpo: 44720
.. date: 2021-07-24-02-17-59
.. nonce: shU5Qm
.. section: Library

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

..

.. bpo: 44704
.. date: 2021-07-21-23-16-30
.. nonce: iqHLxQ
.. section: Library

The implementation of ``collections.abc.Set._hash()`` now matches that of
``frozenset.__hash__()``.

..

.. bpo: 44666
.. date: 2021-07-21-10-43-22
.. nonce: CEThkv
.. section: Library

Fixed issue in :func:`compileall.compile_file` when ``sys.stdout`` is
redirected. Patch by Stefan Hölzl.

..

.. bpo: 40897
.. date: 2021-07-16-13-40-31
.. nonce: aveAre
.. section: Library

Give priority to using the current class constructor in
:func:`inspect.signature`. Patch by Weipeng Hong.

..

.. bpo: 44608
.. date: 2021-07-13-09-01-33
.. nonce: R3IcM1
.. section: Library

Fix memory leak in :func:`_tkinter._flatten` if it is called with a sequence
or set, but not list or tuple.

..

.. bpo: 41928
.. date: 2021-07-09-07-14-37
.. nonce: Q1jMrr
.. section: Library

Update :func:`shutil.copyfile` to raise :exc:`FileNotFoundError` instead of
confusing :exc:`IsADirectoryError` when a path ending with a
:const:`os.path.sep` does not exist; :func:`shutil.copy` and
:func:`shutil.copy2` are also affected.

..

.. bpo: 44566
.. date: 2021-07-05-18-13-25
.. nonce: o51Bd1
.. section: Library

handle StopIteration subclass raised from @contextlib.contextmanager
generator

..

.. bpo: 44558
.. date: 2021-07-04-21-16-53
.. nonce: cm7Slv
.. section: Library

Make the implementation consistency of :func:`~operator.indexOf` between C
and Python versions. Patch by Dong-hee Na.

..

.. bpo: 41249
.. date: 2021-07-04-11-33-34
.. nonce: sHdwBE
.. section: Library

Fixes ``TypedDict`` to work with ``typing.get_type_hints()`` and postponed
evaluation of annotations across modules.

..

.. bpo: 44461
.. date: 2021-06-29-21-17-17
.. nonce: acqRnV
.. section: Library

Fix bug with :mod:`pdb`'s handling of import error due to a package which
does not have a ``__main__`` module

..

.. bpo: 42892
.. date: 2021-06-24-19-16-20
.. nonce: qvRNhI
.. section: Library

Fixed an exception thrown while parsing a malformed multipart email by
:class:`email.message.EmailMessage`.

..

.. bpo: 27827
.. date: 2021-06-12-21-25-35
.. nonce: TMWh1i
.. section: Library

:meth:`pathlib.PureWindowsPath.is_reserved` now identifies a greater range
of reserved filenames, including those with trailing spaces or colons.

..

.. bpo: 34266
.. date: 2021-06-10-21-53-46
.. nonce: k3fxnm
.. section: Library

Handle exceptions from parsing the arg of :mod:`pdb`'s run/restart command.

..

.. bpo: 27334
.. date: 2021-05-18-00-17-21
.. nonce: 32EJZi
.. section: Library

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

..

.. bpo: 43853
.. date: 2021-04-15-12-02-17
.. nonce: XXCVAp
.. section: Library

Improved string handling for :mod:`sqlite3` user-defined functions and
aggregates:

* It is now possible to pass strings with embedded null characters to UDFs
* Conversion failures now correctly raise :exc:`MemoryError`

Patch by Erlend E. Aasland.

..

.. bpo: 43048
.. date: 2021-02-06-05-34-01
.. nonce: yCPUmo
.. section: Library

Handle `RecursionError` in :class:`~traceback.TracebackException`'s
constructor, so that long exceptions chains are truncated instead of causing
traceback formatting to fail.

..

.. bpo: 41402
.. date: 2020-07-26-18-17-30
.. nonce: YRkVkp
.. section: Library

Fix :meth:`email.message.EmailMessage.set_content` when called with binary
data and ``7bit`` content transfer encoding.

..

.. bpo: 32695
.. date: 2020-07-13-23-46-59
.. nonce: tTqqXe
.. section: Library

The *compresslevel* and *preset* keyword arguments of :func:`tarfile.open`
are now both documented and tested.

..

.. bpo: 34990
.. date: 2020-04-24-20-39-38
.. nonce: 3SmL9M
.. section: Library

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
.. date: 2020-01-16-23-41-16
.. nonce: VzzYZz
.. section: Library

Fix ``test___all__`` on platforms lacking a shared memory implementation.

..

.. bpo: 30256
.. date: 2019-09-25-13-54-41
.. nonce: wBkzox
.. section: Library

Pass multiprocessing BaseProxy argument ``manager_owned`` through AutoProxy.

..

.. bpo: 27513
.. date: 2019-06-03-23-53-25
.. nonce: qITN7d
.. section: Library

:func:`email.utils.getaddresses` now accepts :class:`email.header.Header`
objects along with string values. Patch by Zackery Spytz.

..

.. bpo: 33349
.. date: 2018-04-24-14-25-07
.. nonce: Y_0LIr
.. section: Library

lib2to3 now recognizes async generators everywhere.

..

.. bpo: 29298
.. date: 2017-09-20-14-43-03
.. nonce: _78CSN
.. section: Library

Fix ``TypeError`` when required subparsers without ``dest`` do not receive
arguments. Patch by Anthony Sottile.

..

.. bpo: 44903
.. date: 2021-08-13-19-08-03
.. nonce: aJuvQF
.. section: Documentation

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 <https://wiki.python.org/moin/GuiProgramming>`.

..

.. bpo: 44693
.. date: 2021-07-25-23-04-15
.. nonce: JuCbNq
.. section: Documentation

Update the definition of __future__ in the glossary by replacing the
confusing word "pseudo-module" with a more accurate description.

..

.. bpo: 35183
.. date: 2021-07-22-08-28-03
.. nonce: p9BWTB
.. section: Documentation

Add typical examples to os.path.splitext docs

..

.. bpo: 30511
.. date: 2021-07-20-21-03-18
.. nonce: eMFkRi
.. section: Documentation

Clarify that :func:`shutil.make_archive` is not thread-safe due to reliance
on changing the current working directory.

..

.. bpo: 44561
.. date: 2021-07-18-22-43-14
.. nonce: T7HpWm
.. section: Documentation

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: 42958
.. date: 2021-07-15-11-19-03
.. nonce: gC5IHM
.. section: Documentation

Updated the docstring and docs of :func:`filecmp.cmp` to be more accurate
and less confusing especially in respect to *shallow* arg.

..

.. bpo: 44558
.. date: 2021-07-03-18-25-17
.. nonce: 0pTknl
.. section: Documentation

Match the docstring and python implementation of :func:`~operator.countOf`
to the behavior of its c implementation.

..

.. bpo: 44544
.. date: 2021-07-02-14-02-29
.. nonce: _5_aCz
.. section: Documentation

List all kwargs for :func:`textwrap.wrap`, :func:`textwrap.fill`, and
:func:`textwrap.shorten`. Now, there are nav links to attributes of
:class:`TextWrap`, which makes navigation much easier while minimizing
duplication in the documentation.

..

.. bpo: 38062
.. date: 2021-06-28-12-13-48
.. nonce: 9Ehp9O
.. section: Documentation

Clarify that atexit uses equality comparisons internally.

..

.. bpo: 43066
.. date: 2021-06-24-14-37-16
.. nonce: Ti7ahX
.. section: Documentation

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

..

.. bpo: 27752
.. date: 2021-06-18-18-04-53
.. nonce: NEByNk
.. section: Documentation

Documentation of csv.Dialect is more descriptive.

..

.. bpo: 44453
.. date: 2021-06-18-06-44-45
.. nonce: 3PIkj2
.. section: Documentation

Fix documentation for the return type of :func:`sysconfig.get_path`.

..

.. bpo: 39498
.. date: 2020-01-30-05-18-48
.. nonce: Nu3sFL
.. section: Documentation

Add a "Security Considerations" index which links to standard library
modules that have explicitly documented security considerations.

..

.. bpo: 33479
.. date: 2018-05-19-15-59-29
.. nonce: 4cLlxo
.. section: Documentation

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,

..

.. bpo: 25130
.. date: 2021-08-27-22-37-19
.. nonce: ig4oJe
.. section: Tests

Add calls of :func:`gc.collect` in tests to support PyPy.

..

.. bpo: 45011
.. date: 2021-08-26-14-20-44
.. nonce: mQZdXU
.. section: Tests

Made tests relying on the :mod:`_asyncio` C extension module optional to
allow running on alternative Python implementations. Patch by Serhiy
Storchaka.

..

.. bpo: 44949
.. date: 2021-08-18-18-30-12
.. nonce: VE5ENv
.. section: Tests

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: 44852
.. date: 2021-08-06-18-36-04
.. nonce: sUL8YX
.. section: Tests

Add ability to wholesale silence DeprecationWarnings while running the
regression test suite.

..

.. bpo: 40928
.. date: 2021-08-06-00-07-15
.. nonce: aIwb6G
.. section: Tests

Notify users running test_decimal regression tests on macOS of potential
harmless "malloc can't allocate region" messages spewed by test_decimal.

..

.. bpo: 44734
.. date: 2021-07-24-20-09-15
.. nonce: KKsNOV
.. section: Tests

Fixed floating point precision issue in turtle tests.

..

.. bpo: 44708
.. date: 2021-07-22-16-38-39
.. nonce: SYNaac
.. section: Tests

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

..

.. bpo: 30256
.. date: 2019-09-25-18-10-10
.. nonce: A5i76Q
.. section: Tests

Add test for nested queues when using ``multiprocessing`` shared objects
``AutoProxy[Queue]`` inside ``ListProxy`` and ``DictProxy``

..

.. bpo: 44535
.. date: 2021-06-30-02-32-46
.. nonce: M9iN4-
.. section: Build

Enable building using a Visual Studio 2022 install on Windows.

..

.. bpo: 43298
.. date: 2021-06-19-11-50-03
.. nonce: 9ircMb
.. section: Build

Improved error message when building without a Windows SDK installed.

..

.. bpo: 45007
.. date: 2021-08-27-23-50-02
.. nonce: NIBlVG
.. section: Windows

Update to OpenSSL 1.1.1l in Windows build

..

.. bpo: 44572
.. date: 2021-07-13-15-32-49
.. nonce: gXvhDc
.. section: Windows

Avoid consuming standard input in the :mod:`platform` module

..

.. bpo: 40263
.. date: 2020-04-13-15-20-28
.. nonce: 1KKEbu
.. section: Windows

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.

..

.. bpo: 45007
.. date: 2021-08-30-00-04-10
.. nonce: pixqUB
.. section: macOS

Update macOS installer builds to use OpenSSL 1.1.1l.

..

.. bpo: 44689
.. date: 2021-07-20-22-27-01
.. nonce: mmT_xH
.. section: macOS

:meth:`ctypes.util.find_library` now works correctly on macOS 11 Big Sur
even if Python is built on an older version of macOS.  Previously, when
built on older macOS systems, ``find_library`` was not able to find  macOS
system libraries when running on Big Sur due to changes in  how system
libraries are stored.
