This article explains the new features in Python 3.9, compared to 3.8.
Prerelease users should be aware that this document is currently in draft form. It will be updated substantially as Python 3.9 moves towards release, so it’s worth checking back even after reading earlier versions.
Added a new coroutine
that schedules a shutdown for the default executor that waits on the
ThreadPoolExecutor to finish closing. Also,
asyncio.run() has been updated to use the new coroutine.
(Contributed by Kyle Stanley in bpo-34037.)
In a subinterpreter, spawning a daemon thread now raises a
threads were never supported in subinterpreters. Previously, the subinterpreter
finalization crashed with a Python fatal error if a daemon thread was still
(Contributed by Victor Stinner in bpo-37266.)
The activation scripts provided by
venv now all specify their prompt
customization consistently by always using the value specified by
__VENV_PROMPT__. Previously some scripts unconditionally used
__VENV_PROMPT__, others only if it happened to be set (which was the default
case), and one used
(Contributed by Brett Cannon in bpo-37663.)
To improve consistency with import statements,
ImportError instead of
ValueError for invalid relative
(Contributed by Ngalim Siregar in bpo-37444.)
Porting to Python 3.9
This section lists previously described changes and other bugfixes that may require changes to your code.
Changes in the Python API
ImportErrorwhere it previously raised
ValueError. Callers catching the specific exception type and supporting both Python 3.9 and earlier versions will need to catch both using
except (ImportError, ValueError):.
venvactivation scripts no longer special-case when
__VENV_PROMPT__is set to