What’s new in Python 3.15¶
- Editor:
TBD
This article explains the new features in Python 3.15, compared to 3.14.
For full details, see the changelog.
Note
Prerelease users should be aware that this document is currently in draft form. It will be updated substantially as Python 3.15 moves towards release, so it’s worth checking back even after reading earlier versions.
Summary — release highlights¶
New features¶
Other language changes¶
Several error messages incorrectly using the term “argument” have been corrected. (Contributed by Stan Ulbrych in gh-133382.)
New modules¶
None yet.
Improved modules¶
dbm¶
Added new
reorganize()
methods todbm.dumb
anddbm.sqlite3
which allow to recover unused free space previously occupied by deleted entries. (Contributed by Andrea Oliveri in gh-134004.)Add the
'm'
flag fordbm.gnu.open()
which allows to disable the use of mmap(2). This may harm performance, but improve crash tolerance. (Contributed by Serhiy Storchaka in gh-66234.)
difflib¶
Improved the styling of HTML diff pages generated by the
difflib.HtmlDiff
class, and migrated the output to the HTML5 standard. (Contributed by Jiahao Li in gh-134580.)
math¶
Add
math.isnormal()
andmath.issubnormal()
functions. (Contributed by Sergey B Kirpichev in gh-132908.)
os.path¶
The strict parameter to
os.path.realpath()
accepts a new value,os.path.ALLOW_MISSING
. If used, errors other thanFileNotFoundError
will be re-raised; the resulting path can be missing but it will be free of symlinks. (Contributed by Petr Viktorin for CVE 2025-4517.)
shelve¶
sqlite3¶
ssl¶
Indicate through
ssl.HAS_PSK_TLS13
whether thessl
module supports “External PSKs” in TLSv1.3, as described in RFC 9258. (Contributed by Will Childs-Klein in gh-133624.)
tarfile¶
data_filter()
now normalizes symbolic link targets in order to avoid path traversal attacks. (Contributed by Petr Viktorin in gh-127987 and CVE 2025-4138.)extractall()
now skips fixing up directory attributes when a directory was removed or replaced by another kind of file. (Contributed by Petr Viktorin in gh-127987 and CVE 2024-12718.)extract()
andextractall()
now (re-)apply the extraction filter when substituting a link (hard or symbolic) with a copy of another archive member, and when fixing up directory attributes. The former raises a new exception,LinkFallbackError
. (Contributed by Petr Viktorin for CVE 2025-4330 and CVE 2024-12718.)extract()
andextractall()
no longer extract rejected members whenerrorlevel()
is zero. (Contributed by Matt Prodani and Petr Viktorin in gh-112887 and CVE 2025-4435.)
zlib¶
Allow combining two Adler-32 checksums via
adler32_combine()
. (Contributed by Callum Attryde and Bénédikt Tran in gh-134635.)Allow combining two CRC-32 checksums via
crc32_combine()
. (Contributed by Bénédikt Tran in gh-134635.)
Optimizations¶
module_name¶
TODO
Deprecated¶
hashlib¶
In hash function constructors such as
new()
or the direct hash-named constructors such asmd5()
andsha256()
, their optional initial data parameter could also be passed a keyword argument nameddata=
orstring=
in varioushashlib
implementations.Support for the
string
keyword argument name is now deprecated and is slated for removal in Python 3.19. Prefer passing the initial data as a positional argument for maximum backwards compatibility.(Contributed by Bénédikt Tran in gh-134978.)
Removed¶
ctypes¶
Removed the undocumented function
ctypes.SetPointerType()
, which has been deprecated since Python 3.13. (Contributed by Bénédikt Tran in gh-133866.)
http.server¶
Removed the
CGIHTTPRequestHandler
class and the--cgi
flag from the python -m http.server command-line interface. They were deprecated in Python 3.13. (Contributed by Bénédikt Tran in gh-133810.)
platform¶
Removed the
platform.java_ver()
function, which was deprecated since Python 3.13. (Contributed by Alexey Makridenko in gh-133604.)
sysconfig¶
Removed the check_home parameter of
sysconfig.is_python_build()
. (Contributed by Filipe Laíns in gh-92897.)
threading¶
typing¶
The undocumented keyword argument syntax for creating
NamedTuple
classes (for example,Point = NamedTuple("Point", x=int, y=int)
) is no longer supported. Use the class-based syntax or the functional syntax instead. (Contributed by Bénédikt Tran in gh-133817.)Using
TD = TypedDict("TD")
orTD = TypedDict("TD", None)
to construct aTypedDict
type with zero field is no longer supported. Useclass TD(TypedDict): pass
orTD = TypedDict("TD", {})
instead. (Contributed by Bénédikt Tran in gh-133823.)
wave¶
Removed the
getmark()
,setmark()
andgetmarkers()
methods of theWave_read
andWave_write
classes, which were deprecated since Python 3.13. (Contributed by Bénédikt Tran in gh-133873.)
Porting to Python 3.15¶
This section lists previously described changes and other bugfixes that may require changes to your code.
Build changes¶
C API changes¶
New features¶
Add
PySys_GetAttr()
,PySys_GetAttrString()
,PySys_GetOptionalAttr()
, andPySys_GetOptionalAttrString()
functions as replacements forPySys_GetObject()
. (Contributed by Serhiy Storchaka in gh-108512.)Add
PyUnstable_Unicode_GET_CACHED_HASH
to get the cached hash of a string. See the documentation for caveats. (Contributed by Petr Viktorin in gh-131510)
Porting to Python 3.15¶
sqlite3.Connection
APIs has been cleaned up.All parameters of
sqlite3.connect()
except database are now keyword-only.The first three parameters of methods
create_function()
andcreate_aggregate()
are now positional-only.The first parameter of methods
set_authorizer()
,set_progress_handler()
andset_trace_callback()
is now positional-only.
(Contributed by Serhiy Storchaka in gh-133595.)
Deprecated C APIs¶
TODO
Removed C APIs¶
Remove deprecated
PyUnicode
functions:PyUnicode_AsDecodedObject()
: UsePyCodec_Decode()
instead.PyUnicode_AsDecodedUnicode()
: UsePyCodec_Decode()
instead; Note that some codecs (for example, “base64”) may return a type other thanstr
, such asbytes
.PyUnicode_AsEncodedObject()
: UsePyCodec_Encode()
instead.PyUnicode_AsEncodedUnicode()
: UsePyCodec_Encode()
instead; Note that some codecs (for example, “base64”) may return a type other thanbytes
, such asstr
.
(Contributed by Stan Ulbrych in gh-133612)
PyImport_ImportModuleNoBlock()
: deprecated alias ofPyImport_ImportModule()
. (Contributed by Bénédikt Tran in gh-133644.)
The following functions are removed in favor of PyConfig_Get()
.
The pythoncapi-compat project can be used to get PyConfig_Get()
on Python 3.13 and older.
Python initialization functions:
Py_GetExecPrefix()
: usePyConfig_Get("base_exec_prefix")
(sys.base_exec_prefix
) instead. UsePyConfig_Get("exec_prefix")
(sys.exec_prefix
) if virtual environments need to be handled.Py_GetPath()
: usePyConfig_Get("module_search_paths")
(sys.path
) instead.Py_GetPrefix()
: usePyConfig_Get("base_prefix")
(sys.base_prefix
) instead. UsePyConfig_Get("prefix")
(sys.prefix
) if virtual environments need to be handled.Py_GetProgramFullPath()
: usePyConfig_Get("executable")
(sys.executable
) instead.Py_GetProgramName()
: usePyConfig_Get("executable")
(sys.executable
) instead.Py_GetPythonHome()
: usePyConfig_Get("home")
or thePYTHONHOME
environment variable instead.
(Contributed by Bénédikt Tran in gh-133644.)