C API
gh-85283 [https://github.com/python/cpython/issues/85283]: If the
Py_LIMITED_API
macro is defined,Py_BUILD_CORE
,Py_BUILD_CORE_BUILTIN
andPy_BUILD_CORE_MODULE
macros are now undefined by
. Patch by Victor Stinner.gh-110289 [https://github.com/python/cpython/issues/110289]: Add
PyUnicode_EqualToUTF8AndSize()
andPyUnicode_EqualToUTF8()
functions.gh-110235 [https://github.com/python/cpython/issues/110235]: Raise
TypeError
for duplicate/unknown fields inPyStructSequence
constructor. Patched by Xuehai Pan.gh-110014 [https://github.com/python/cpython/issues/110014]: Remove undocumented
PY_TIMEOUT_MAX
constant from the limited C API. Patch by Victor Stinner.gh-109521 [https://github.com/python/cpython/issues/109521]:
PyImport_GetImporter()
now sets RuntimeError if it fails to getsys.path_hooks
orsys.path_importer_cache
or they are not list and dict correspondingly. Previously it could return NULL without setting error in obscure cases, crash or raise SystemError if these attributes have wrong type.gh-108724 [https://github.com/python/cpython/issues/108724]: Add
PyMutex
internal-only lightweight locking API.gh-85283 [https://github.com/python/cpython/issues/85283]: Add
PySys_AuditTuple()
function: similar toPySys_Audit()
, but pass event arguments as a Pythontuple
object. Patch by Victor Stinner.gh-108867 [https://github.com/python/cpython/issues/108867]: Add
PyThreadState_GetUnchecked()
function: similar toPyThreadState_Get()
, but don't kill the process with a fatal error if it is NULL. The caller is responsible to check if the result is NULL. Previously, the function was private and known asPyThreadStateUncheckedGet()
. Patch by Victor Stinner.gh-108765 [https://github.com/python/cpython/issues/108765]:
Python.h
no longer includes the
standard header file. If needed, it should now be included explicitly. For example, it providesisalpha()
andtolower()
functions which are locale dependent. Python provides locale independent functions, likePy_ISALPHA()
andPy_TOLOWER()
. Patch by Victor Stinner.gh-108765 [https://github.com/python/cpython/issues/108765]:
Python.h
no longer includes the
standard header file. If needed, it should now be included explicitly. For example, it provides the functions:close()
,getpagesize()
,getpid()
andsysconf()
. Patch by Victor Stinner.gh-108765 [https://github.com/python/cpython/issues/108765]:
Python.h
no longer includes the
standard header. It was included for thefinite()
function which is now provided by the
header. It should now be included explicitly if needed. Remove also theHAVE_IEEEFP_H
macro. Patch by Victor Stinner.gh-108765 [https://github.com/python/cpython/issues/108765]:
Python.h
no longer includes these standard header files:
,
and
. If needed, they should now be included explicitly. For example,
provides theclock()
andgmtime()
functions,
provides theselect()
function, and
provides thefutimes()
,gettimeofday()
andsetitimer()
functions. Patch by Victor Stinner.gh-108511 [https://github.com/python/cpython/issues/108511]: Add functions
PyObject_HasAttrWithError()
,PyObject_HasAttrStringWithError()
,PyMapping_HasKeyWithError()
andPyMapping_HasKeyStringWithError()
.gh-107073 [https://github.com/python/cpython/issues/107073]: Add
PyObject_VisitManagedDict()
andPyObject_ClearManagedDict()
functions which must be called by the traverse and clear functions of a type usingPy_TPFLAGS_MANAGED_DICT
flag. Patch by Victor Stinner.gh-108634 [https://github.com/python/cpython/issues/108634]: Python built with
configure
--with-trace-refs
(tracing references) now supports the Limited API. Patch by Victor Stinner.gh-108014 [https://github.com/python/cpython/issues/108014]: Add
PyLong_AsInt()
function: similar toPyLong_AsLong()
, but store the result in a C int instead of a C long. Previously, it was known as the private functionPyLongAsInt()
(with an underscore prefix). Patch by Victor Stinner.gh-108314 [https://github.com/python/cpython/issues/108314]: Add
PyDict_ContainsString()
function: same asPyDict_Contains()
, but key is specified as a const char UTF-8 encoded bytes string, rather than a PyObject. Patch by Victor Stinner.gh-108337 [https://github.com/python/cpython/issues/108337]: Add atomic operations on additional data types in pyatomic.h.
gh-108014 [https://github.com/python/cpython/issues/108014]: Add
Py_IsFinalizing()
function: check if the main Python interpreter is shutting down. Patch by Victor Stinner.gh-107916 [https://github.com/python/cpython/issues/107916]: C API functions
PyErr_SetFromErrnoWithFilename()
,PyErr_SetExcFromWindowsErrWithFilename()
andPyErr_SetFromWindowsErrWithFilename()
save now the error code before callingPyUnicode_DecodeFSDefault()
.gh-107915 [https://github.com/python/cpython/issues/107915]: Such C API functions as
PyErr_SetString()
,PyErr_Format()
,PyErr_SetFromErrnoWithFilename()
and many others no longer crash or ignore errors if it failed to format the error message or decode the filename. Instead, they keep a corresponding error.gh-107810 [https://github.com/python/cpython/issues/107810]: Improve
DeprecationWarning
for uses ofPyType_Spec
with metaclasses that have customtp_new
.gh-107249 [https://github.com/python/cpython/issues/107249]: Implement the
Py_UNUSED
macro for Windows MSVC compiler. Patch by Victor Stinner.gh-107226 [https://github.com/python/cpython/issues/107226]:
PyModule_AddObjectRef()
is now only available in the limited API version 3.10 or later.gh-106320 [https://github.com/python/cpython/issues/106320]: Remove private
PyUnicodeAsString()
alias toPyUnicode_AsUTF8()
. It was kept for backward compatibility with Python 3.0 - 3.2. ThePyUnicode_AsUTF8()
is available since Python 3.3. ThePyUnicode_AsUTF8String()
function can be used to keep compatibility with Python 3.2 and older. Patch by Victor Stinner.gh-106572 [https://github.com/python/cpython/issues/106572]: Convert
PyObject_DelAttr()
andPyObject_DelAttrString()
macros to functions. Patch by Victor Stinner.gh-106307 [https://github.com/python/cpython/issues/106307]: Add
PyMapping_GetOptionalItem()
function.gh-106521 [https://github.com/python/cpython/issues/106521]: Add
PyObject_GetOptionalAttr()
andPyObject_GetOptionalAttrString()
functions.gh-106320 [https://github.com/python/cpython/issues/106320]: Remove
PyInterpreterStateGet()
alias toPyInterpreterState_Get()
which was kept for backward compatibility with Python 3.8. Patch by Victor Stinner.gh-106316 [https://github.com/python/cpython/issues/106316]: Remove
cpython/pytime.h
header file: it only contained private functions. Patch by Victor Stinner.gh-106023 [https://github.com/python/cpython/issues/106023]: Remove private
PyObjectFastCall()
function: usePyObject_Vectorcall()
which is available since Python 3.8 ( PEP 590 [https://peps.python.org/pep-0590/]). Patch by Victor Stinner.gh-106168 [https://github.com/python/cpython/issues/106168]: If Python is built in debug mode or
with assertions
,PyTuple_SET_ITEM()
andPyList_SET_ITEM()
now check the index argument with an assertion. If the assertion fails, make sure that the size is set before. Patch by Victor Stinner.gh-106084 [https://github.com/python/cpython/issues/106084]: Remove the old aliases to functions calling functions which were kept for backward compatibility with Python 3.8 provisional API:
PyObjectCallMethodNoArgs()
: usePyObject_CallMethodNoArgs()
PyObjectCallMethodOneArg()
: usePyObject_CallMethodOneArg()
PyObjectCallOneArg()
: usePyObject_CallOneArg()
PyObjectFastCallDict()
: usePyObject_VectorcallDict()
PyObjectVectorcall()
: usePyObject_Vectorcall()
PyObjectVectorcallMethod()
: usePyObject_VectorcallMethod()
PyVectorcallFunction()
: usePyVectorcall_Function()
Just remove the underscore prefix to update your code. Patch by Victor Stinner.
gh-106004 [https://github.com/python/cpython/issues/106004]: Adds
PyDict_GetItemRef()
andPyDict_GetItemStringRef()
functions: similar toPyDict_GetItemWithError()
but returning a strong reference instead of a borrowed reference. Patch by Victor Stinner.gh-105927 [https://github.com/python/cpython/issues/105927]: Deprecate the
PyWeakref_GetObject()
andPyWeakref_GET_OBJECT()
functions: use the newPyWeakref_GetRef()
function instead. Patch by Victor Stinner.gh-105927 [https://github.com/python/cpython/issues/105927]: Add
PyWeakref_GetRef()
function: similar toPyWeakref_GetObject()
but returns a strong reference, orNULL
if the referent is no longer live. Patch by Victor Stinner.gh-105922 [https://github.com/python/cpython/issues/105922]: Add
PyImport_AddModuleRef()
: similar toPyImport_AddModule()
, but return a strong reference instead of a borrowed reference. Patch by Victor Stinner.gh-105227 [https://github.com/python/cpython/issues/105227]: The new
PyType_GetDict()
provides the dictionary for the given type object that is normally exposed bycls.__dict__
. Normally it's sufficient to usetp_dict
, but for the static builtin typestp_dict
is now alwaysNULL
.PyType_GetDict()
provides the correct dict object instead.gh-105375 [https://github.com/python/cpython/issues/105375]: Fix a bug in
PyErr_WarnExplicit()
where an exception could end up being overwritten if the API failed internally.gh-105603 [https://github.com/python/cpython/issues/105603]: We've renamed the new (in 3.12)
PyInterpreterConfig.own_gil
toPyInterpreterConfig.gil
and changed the meaning of the value from "bool" to an integer with supported values ofPyInterpreterConfig_DEFAULT_GIL
,PyInterpreterConfig_SHARED_GIL
, andPyInterpreterConfig_OWN_GIL
. The default is "shared".gh-105387 [https://github.com/python/cpython/issues/105387]: In the limited C API version 3.12,
Py_INCREF()
andPy_DECREF()
functions are now implemented as opaque function calls to hide implementation details. Patch by Victor Stinner.gh-105396 [https://github.com/python/cpython/issues/105396]: Deprecate the
PyImport_ImportModuleNoBlock()
function which is just an alias toPyImport_ImportModule()
since Python 3.3. Patch by Victor Stinner.gh-103968 [https://github.com/python/cpython/issues/103968]:
PyType_FromMetaclass()
now allows metaclasses withtp_new
set toNULL
.gh-105268 [https://github.com/python/cpython/issues/105268]: Remove the old private, undocumented and untested
PyGCFINALIZED()
macro which was kept for backward compatibility with Python 3.8 and older. Patch by Victor Stinner.gh-105182 [https://github.com/python/cpython/issues/105182]: Remove
PyEval_AcquireLock()
andPyEval_ReleaseLock()
functions, deprecated in Python 3.2. Patch by Victor Stinner.gh-105182 [https://github.com/python/cpython/issues/105182]: Remove
PyEval_InitThreads()
andPyEval_ThreadsInitialized()
functions, deprecated in Python 3.9. Patch by Victor Stinner.gh-105145 [https://github.com/python/cpython/issues/105145]: Deprecate old Python initialization functions:
Patch by Victor Stinner.
gh-85275 [https://github.com/python/cpython/issues/85275]:
PyObject_AsCharBuffer()
,PyObject_AsReadBuffer()
,PyObject_CheckReadBuffer()
, andPyObject_AsWriteBuffer()
are removed. Please migrate to new buffer protocol;PyObject_GetBuffer()
andPyBuffer_Release()
.gh-105156 [https://github.com/python/cpython/issues/105156]: Deprecate the old
Py_UNICODE
andPY_UNICODE_TYPE
types: use directly thewchar_t
type instead. Since Python 3.3,Py_UNICODE
andPY_UNICODE_TYPE
are just aliases towchar_t
. Patch by Victor Stinner.gh-105145 [https://github.com/python/cpython/issues/105145]: Remove the following old functions to configure the Python initialization, deprecated in Python 3.11:
PySys_AddWarnOptionUnicode()
PySys_AddWarnOption()
PySys_AddXOption()
PySys_HasWarnOptions()
PySys_SetArgvEx()
PySys_SetArgv()
PySys_SetPath()
Py_SetPath()
Py_SetProgramName()
Py_SetPythonHome()
Py_SetStandardStreamEncoding()
PySetProgramFullPath()
Patch by Victor Stinner.
gh-105107 [https://github.com/python/cpython/issues/105107]: Remove functions deprecated in Python 3.9.
PyEval_CallObject()
,PyEval_CallObjectWithKeywords()
: usePyObject_CallNoArgs()
andPyObject_Call()
(positional arguments must not be NULL) instead.PyEval_CallFunction()
: usePyObject_CallFunction()
instead.PyEval_CallMethod()
: usePyObject_CallMethod()
instead.PyCFunction_Call()
: usePyObject_Call()
instead.
Patch by Victor Stinner.
gh-105115 [https://github.com/python/cpython/issues/105115]:
PyTypeObject.tp_bases
(andtp_mro
) for builtin static types are now shared by all interpreters, whereas in 3.12beta1 they were stored onPyInterpreterState
. Also note that now the tuples are immortal objects.gh-105071 [https://github.com/python/cpython/issues/105071]: Add
PyUnstable_Exc_PrepReraiseStar
to the unstable C api to expose the implementation ofexcept*
.gh-104922 [https://github.com/python/cpython/issues/104922]:
PY_SSIZE_T_CLEAN
is no longer required to use'#'
formats in APIs likePyArg_ParseTuple()
andPy_BuildValue()
. They usesPy_ssize_t
for'#'
regardlessPY_SSIZE_T_CLEAN
.gh-104584 [https://github.com/python/cpython/issues/104584]: Add an unstable C API for hooking in an optimizer. This is mainly internal, but marked "unstable" to allow third-party experimentation.
gh-104668 [https://github.com/python/cpython/issues/104668]: Don't call
PyOS_InputHook
orPyOS_ReadlineFunctionPointer
in subinterpreters, since it's generally difficult to avoid using global state in their registered callbacks. This also avoids situations where extensions may find themselves running in a subinterpreter they don't support (or haven't yet been loaded in).bpo-42327 [https://bugs.python.org/issue?@action=redirect&bpo=42327]: Add
PyModule_Add()
function: similar toPyModule_AddObjectRef()
andPyModule_AddObject()
, but always steals a reference to the value.bpo-40309 [https://bugs.python.org/issue?@action=redirect&bpo=40309]: Properly handle trailing spaces before closing parenthesis in
Py_BuildValue()
format strings.
Python 3.12.0 beta 1
Release date: 2023-05-22
安全性
gh-99889 [https://github.com/python/cpython/issues/99889]: Fixed a security in flaw in
uu.decode()
that could allow for directory traversal based on the input if noout_file
was specified.gh-104049 [https://github.com/python/cpython/issues/104049]: Do not expose the local on-disk location in directory indexes produced by
http.client.SimpleHTTPRequestHandler
.gh-99108 [https://github.com/python/cpython/issues/99108]: Upgrade builtin
hashlib
SHA3 implementation to a verified implementation from theHACL*
project. Used when OpenSSL is not present or lacks SHA3.gh-102153 [https://github.com/python/cpython/issues/102153]:
urllib.parse.urlsplit()
now strips leading C0 control and space characters following the specification for URLs defined by WHATWG in response to CVE 2023-24329 [https://www.cve.org/CVERecord?id=CVE-2023-24329]. Patch by Illia Volochii.
核心与内置函数
gh-102856 [https://github.com/python/cpython/issues/102856]: Implement PEP 701 changes in the
tokenize
module. Patch by Marta Gómez Macías and Pablo Galindo Salgadogh-104615 [https://github.com/python/cpython/issues/104615]: Fix wrong ordering of assignments in code like
a, a = x, y
. Contributed by Carl Meyer.gh-104572 [https://github.com/python/cpython/issues/104572]: Improve syntax error message for invalid constructs in PEP 695 [https://peps.python.org/pep-0695/] contexts and in annotations when
from __future__ import annotations
is active.gh-104482 [https://github.com/python/cpython/issues/104482]: Fix three error handling bugs in ast.c's validation of pattern matching statements.
gh-102818 [https://github.com/python/cpython/issues/102818]: Do not add a frame to the traceback in the
sys.setprofile
andsys.settrace
trampoline functions. This ensures that frames are not duplicated if an exception is raised in the callback function, and ensures that frames are not omitted if a C callback is used and that does not add the frame.gh-104405 [https://github.com/python/cpython/issues/104405]: Fix an issue where some bytecode instructions could ignore PEP 523 [https://peps.python.org/pep-0523/] when "inlining" calls.
gh-103082 [https://github.com/python/cpython/issues/103082]: Change behavior of
sys.monitoring.events.LINE
events insys.monitoring
: Line events now occur when a new line is reached dynamically, instead of using a static approximation, as before. This makes the behavior very similar to that of "line" events insys.settrace
. This should ease porting of tools from 3.11 to 3.12.gh-104263 [https://github.com/python/cpython/issues/104263]: Fix
float("nan")
to produce a quiet NaN on platforms (like MIPS) where the meaning of the signalling / quiet bit is inverted from its usual meaning. Also introduce a new macroPy_INFINITY
matching C99'sINFINITY
, and refactor internals to rely on C99'sNAN
andINFINITY
macros instead of hardcoding bit patterns for infinities and NaNs. Thanks Sebastian Berg.gh-99113 [https://github.com/python/cpython/issues/99113]: Multiphase init extension modules may now indicate that they support running in subinterpreters that have their own GIL. This is done by using
Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
as the value for thePy_mod_multiple_interpreters
module def slot. Otherwise the module, by default, cannot be imported in such subinterpreters. (This does not affect the main interpreter or subinterpreters that do not have their own GIL.) In addition to the isolation that multiphase init already normally requires, support for per-interpreter GIL involves one additional constraint: threadsafety. If the module has external (linked) dependencies and those libraries have any state that isn't threadsafe then the module must do the additional work to add threadsafety. This should be an uncommon case.gh-99113 [https://github.com/python/cpython/issues/99113]: The GIL is now (optionally) per-interpreter. This is the fundamental change for PEP 684. This is all made possible by virtue of the isolated state of each interpreter in the process. The behavior of the main interpreter remains unchanged. Likewise, interpreters created using
Py_NewInterpreter()
are not affected. To get an interpreter with its own GIL, callPy_NewInterpreterFromConfig()
.gh-104108 [https://github.com/python/cpython/issues/104108]: Multiphase init extension modules may now indicate whether or not they actually support multiple interpreters. By default such modules are expected to support use in multiple interpreters. In the uncommon case that one does not, it may use the new
Py_mod_multiple_interpreters
module def slot. A value of0
means the module does not support them.1
means it does. The default is1
.gh-104142 [https://github.com/python/cpython/issues/104142]: Fix an issue where
list
ortuple
repetition could fail to respect PEP 683 [https://peps.python.org/pep-0683/].gh-104078 [https://github.com/python/cpython/issues/104078]: Improve the performance of
PyObject_HasAttrString()
gh-104066 [https://github.com/python/cpython/issues/104066]: Improve the performance of
hasattr()
for module objects with a missing attribute.gh-104028 [https://github.com/python/cpython/issues/104028]: Reduce object creation while calling callback function from gc. Patch by Donghee Na.
gh-104018 [https://github.com/python/cpython/issues/104018]: Disallow the "z" format specifier in %-format of bytes objects.
gh-102213 [https://github.com/python/cpython/issues/102213]: Fix performance loss when accessing an object's attributes with
__getattr__
defined.gh-103895 [https://github.com/python/cpython/issues/103895]: Improve handling of edge cases in showing
Exception.__notes__
. Ensures that the messages always end with a newline and that string/bytes are not exploded over multiple lines. Patch by Carey Metcalfe.gh-103907 [https://github.com/python/cpython/issues/103907]: Don't modify the refcounts of known immortal objects (
True
,False
, andNone
) in the main interpreter loop.gh-103899 [https://github.com/python/cpython/issues/103899]: Provide a helpful hint in the
TypeError
message when accidentally calling a module object that has a callable attribute of the same name (such asdis.dis()
ordatetime.datetime
).gh-103845 [https://github.com/python/cpython/issues/103845]: Remove both line and instruction instrumentation before adding new ones for monitoring, to avoid newly added instrumentation being removed immediately.
gh-103763 [https://github.com/python/cpython/issues/103763]: Implement PEP 695 [https://peps.python.org/pep-0695/], adding syntactic support for generic classes, generic functions, and type aliases.
A new type X = …
syntax is added for type aliases, which resolves at runtime to an instance of the new class typing.TypeAliasType
. The value is lazily evaluated and is accessible through the .__value__
attribute. This is implemented as a new AST node ast.TypeAlias
.
New syntax (class X[T]: …
, def funcT: …
) is added for defining generic functions and classes. This is implemented as a new type_params
attribute on the AST nodes for classes and functions. This node holds instances of the new AST classes ast.TypeVar
, ast.ParamSpec
, and ast.TypeVarTuple
.
typing.TypeVar
, typing.ParamSpec
, typing.ParamSpecArgs
, typing.ParamSpecKwargs
, typing.TypeVarTuple
, and typing.Generic
are now implemented in C rather than Python.
There are new bytecode instructions LOAD_LOCALS
, LOAD_CLASSDICT_OR_GLOBAL
, and LOAD_CLASSDICT_OR_DEREF
to support correct resolution of names in class namespaces.
Patch by Eric Traut, Larry Hastings, and Jelle Zijlstra.
gh-103801 [https://github.com/python/cpython/issues/103801]: Adds three minor linting fixes to the wasm module caught that were caught by ruff.
gh-103793 [https://github.com/python/cpython/issues/103793]: Optimized asyncio Task creation by deferring expensive string formatting (task name generation) from Task creation to the first time
get_name
is called. This makes asyncio benchmarks up to 5% faster.gh-102310 [https://github.com/python/cpython/issues/102310]: Change the error range for invalid bytes literals.
gh-103590 [https://github.com/python/cpython/issues/103590]: Do not wrap a single exception raised from a
try-except*
construct in anExceptionGroup
.gh-103650 [https://github.com/python/cpython/issues/103650]: Change the perf map format to remove the '0x' prefix from the addresses
gh-102856 [https://github.com/python/cpython/issues/102856]: Implement the required C tokenizer changes for PEP 701. Patch by Pablo Galindo Salgado, Lysandros Nikolaou, Batuhan Taskaya, Marta Gómez Macías and sunmy2019.
gh-100530 [https://github.com/python/cpython/issues/100530]: Clarify the error message raised when the called part of a class pattern isn't actually a class.
gh-101517 [https://github.com/python/cpython/issues/101517]: Fix bug in line numbers of instructions emitted for
except*
.gh-103492 [https://github.com/python/cpython/issues/103492]: Clarify
SyntaxWarning
with literalis
comparison by specifying which literal is problematic, since comparisons usingis
with e.g.None
and bool literals are idiomatic.gh-87729 [https://github.com/python/cpython/issues/87729]: Add
LOAD_SUPER_ATTR
(and a specialization forsuper().method()
) to speed upsuper().method()
andsuper().attr
. This makessuper().method()
roughly 2.3x faster and brings it within 20% of the performance of a simple method call. Patch by Vladimir Matveev and Carl Meyer.gh-103488 [https://github.com/python/cpython/issues/103488]: Change the internal offset distinguishing yield and return target addresses, so that the instruction pointer is correct for exception handling and other stack unwinding.
gh-82012 [https://github.com/python/cpython/issues/82012]: The bitwise inversion operator (
~
) on bool is deprecated. It returns the bitwise inversion of the underlyingint
representation such thatbool(~True) == True
, which can be confusing. Usenot
for logical negation of bools. In the rare case that you really need the bitwise inversion of the underlyingint
, convert to int explicitly~int(x)
.gh-77757 [https://github.com/python/cpython/issues/77757]: Exceptions raised in a typeobject's
_setname__
method are no longer wrapped by aRuntimeError
. Context information is added to the exception as a PEP 678 [https://peps.python.org/pep-0678/] note.gh-103333 [https://github.com/python/cpython/issues/103333]:
AttributeError
now retains thename
attribute when pickled and unpickled.gh-103242 [https://github.com/python/cpython/issues/103242]: Migrate
set_ecdh_curve()
method not to use deprecated OpenSSL APIs. Patch by Donghee Na.gh-103323 [https://github.com/python/cpython/issues/103323]: We've replaced our use of
PyRuntime.tstatecurrent
with a thread-local variable. This is a fairly low-level implementation detail, and there should be no change in behavior.gh-84436 [https://github.com/python/cpython/issues/84436]: The implementation of PEP-683 which adds Immortal Objects by using a fixed reference count that skips reference counting to make objects truly immutable.
gh-102700 [https://github.com/python/cpython/issues/102700]: Allow builtin modules to be submodules. This allows submodules to be statically linked into a CPython binary.
gh-103082 [https://github.com/python/cpython/issues/103082]: Implement PEP 669 [https://peps.python.org/pep-0669/] Low Impact Monitoring for CPython.
gh-88691 [https://github.com/python/cpython/issues/88691]: Reduce the number of inline
CACHE
entries forCALL
.gh-102500 [https://github.com/python/cpython/issues/102500]: Make the buffer protocol accessible in Python code using the new
__buffer__
and__release_buffer__
magic methods. See PEP 688 [https://peps.python.org/pep-0688/] for details. Patch by Jelle Zijlstra.gh-97933 [https://github.com/python/cpython/issues/97933]: PEP 709 [https://peps.python.org/pep-0709/]: inline list, dict and set comprehensions to improve performance and reduce bytecode size.
gh-99184 [https://github.com/python/cpython/issues/99184]: Bypass instance attribute access of
__name__
inrepr
ofweakref.ref
.gh-98003 [https://github.com/python/cpython/issues/98003]: Complex function calls are now faster and consume no C stack space.
bpo-39610 [https://bugs.python.org/issue?@action=redirect&bpo=39610]:
len()
for 0-dimensionalmemoryview
objects (such asmemoryview(ctypes.c_uint8(42))
) now raises aTypeError
. Previously this returned1
, which was not consistent withmem_0d[0]
raising anIndexError
.bpo-31821 [https://bugs.python.org/issue?@action=redirect&bpo=31821]: Fix
pause_reading()
to work when called fromconnection_made()
inasyncio
.
库
gh-104600 [https://github.com/python/cpython/issues/104600]:
functools.update_wrapper()
now sets the__type_params__
attribute (added by PEP 695 [https://peps.python.org/pep-0695/]).gh-104340 [https://github.com/python/cpython/issues/104340]: When an
asyncio
pipe protocol loses its connection due to an error, and the caller doesn't awaitwait_closed()
on the correspondingStreamWriter
, don't log a warning about an exception that was never retrieved. After all, according to theStreamWriter.close()
docs, thewait_closed()
call is optional ("not mandatory").gh-104555 [https://github.com/python/cpython/issues/104555]: Fix issue where an
issubclass()
check comparing a classX
against aruntime-checkable protocol
Y
with non-callable members would not causeTypeError
to be raised if anisinstance()
call had previously been made comparing an instance ofX
toY
. This issue was present in edge cases on Python 3.11, but became more prominent in 3.12 due to some unrelated changes that were made to runtime-checkable protocols. Patch by Alex Waygood.gh-104372 [https://github.com/python/cpython/issues/104372]: Refactored the
_posixsubprocess
internals to avoid Python C API usage between fork and exec when markingpass_fds=
file descriptors inheritable.gh-104484 [https://github.com/python/cpython/issues/104484]: Added case_sensitive argument to
pathlib.PurePath.match()
gh-75367 [https://github.com/python/cpython/issues/75367]: Fix data descriptor detection in
inspect.getattr_static()
.gh-104536 [https://github.com/python/cpython/issues/104536]: Fix a race condition in the internal
multiprocessing.process
cleanup logic that could manifest as an unintendedAttributeError
when callingprocess.close()
.gh-103857 [https://github.com/python/cpython/issues/103857]: Update datetime deprecations' stracktrace to point to the calling line
gh-101520 [https://github.com/python/cpython/issues/101520]: Move the core functionality of the
tracemalloc
module in thePython/
folder, leaving just the module wrapper inModules/
.gh-104392 [https://github.com/python/cpython/issues/104392]: Remove undocumented and unused
paramspectvars
attribute from some classes intyping
.gh-102613 [https://github.com/python/cpython/issues/102613]: Fix issue where
pathlib.Path.glob()
raisedRecursionError
when walking deep directory trees.gh-103000 [https://github.com/python/cpython/issues/103000]: Improve performance of
dataclasses.asdict()
for the common case where dict_factory isdict
. Patch by David C Ellis.gh-104301 [https://github.com/python/cpython/issues/104301]: Allow leading whitespace in disambiguated statements in
pdb
.gh-104139 [https://github.com/python/cpython/issues/104139]: Teach
urllib.parse.unsplit()
to retain the"//"
when assemblingitms-services://?action=generate-bugs
style Apple Platform Deployment [https://support.apple.com/en-gb/guide/deployment/depce7cefc4d/web] URLs.gh-104307 [https://github.com/python/cpython/issues/104307]:
socket.getnameinfo()
now releases the GIL while contacting the DNS servergh-104310 [https://github.com/python/cpython/issues/104310]: Users may now use
importlib.util.allowing_all_extensions()
(a context manager) to temporarily disable the strict compatibility checks for importing extension modules in subinterpreters.gh-87695 [https://github.com/python/cpython/issues/87695]: Fix issue where
pathlib.Path.glob()
raisedOSError
when it encountered a symlink to an overly long path.gh-104265 [https://github.com/python/cpython/issues/104265]: Prevent possible crash by disallowing instantiation of the
_csv.Reader
and_csv.Writer
types. The regression was introduced in 3.10.0a4 with PR 23224 (bpo-14935 [https://bugs.python.org/issue?@action=redirect&bpo=14935]). Patch by Radislav Chugunov.gh-102613 [https://github.com/python/cpython/issues/102613]: Improve performance of
pathlib.Path.glob()
when expanding recursive wildcards ("**
") by merging adjacent wildcards and deduplicating results only when necessary.gh-65772 [https://github.com/python/cpython/issues/65772]: Remove unneeded comments and code in turtle.py.
gh-90208 [https://github.com/python/cpython/issues/90208]: Fixed issue where
pathlib.Path.glob()
returned incomplete results when it encountered aPermissionError
. This method now suppresses allOSError
exceptions, except those raised from callingis_dir()
on the toplevel path.gh-104144 [https://github.com/python/cpython/issues/104144]: Optimize
asyncio.TaskGroup
when usingasyncio.eager_task_factory()
. Skip scheduling a done callback if a TaskGroup task completes eagerly.gh-104144 [https://github.com/python/cpython/issues/104144]: Optimize
asyncio.gather()
when usingasyncio.eager_task_factory()
to complete eagerly if all fututres completed eagerly. Avoid scheduling done callbacks for futures that complete eagerly.gh-104114 [https://github.com/python/cpython/issues/104114]: Fix issue where
pathlib.Path.glob()
returns paths using the case of non-wildcard segments for corresponding path segments, rather than the real filesystem case.gh-104104 [https://github.com/python/cpython/issues/104104]: Improve performance of
pathlib.Path.glob()
by usingre.IGNORECASE
to implement case-insensitive matching.gh-104102 [https://github.com/python/cpython/issues/104102]: Improve performance of
pathlib.Path.glob()
when evaluating patterns that contain'../'
segments.gh-103822 [https://github.com/python/cpython/issues/103822]: Update the return type of
weekday
to the newly added Day attributegh-103629 [https://github.com/python/cpython/issues/103629]: Update the
repr
oftyping.Unpack
according to PEP 692 [https://peps.python.org/pep-0692/].gh-103963 [https://github.com/python/cpython/issues/103963]: Make
dis
display the names of the args forCALL_INTRINSIC_*
.gh-104035 [https://github.com/python/cpython/issues/104035]: Do not ignore user-defined
__getstate__
and__setstate__
methods for slotted frozen dataclasses.gh-103987 [https://github.com/python/cpython/issues/103987]: In
mmap
, fix several bugs that could lead to access to memory-mapped files after they have been invalidated.gh-103977 [https://github.com/python/cpython/issues/103977]: Improve import time of
platform
module.gh-88773 [https://github.com/python/cpython/issues/88773]: Added
turtle.teleport()
to theturtle
module to move a turtle to a new point without tracing a line, visible or invisible. Patch by Liam Gersten.gh-103935 [https://github.com/python/cpython/issues/103935]: Use
io.open_code()
for files to be executed instead of rawopen()
gh-68968 [https://github.com/python/cpython/issues/68968]: Fixed garbled output of
assertEqual()
when an input lacks final newline.gh-100370 [https://github.com/python/cpython/issues/100370]: Fix potential
OverflowError
insqlite3.Connection.blobopen()
for 32-bit builds. Patch by Erlend E. Aasland.gh-102628 [https://github.com/python/cpython/issues/102628]: Substitute CTRL-D with CTRL-Z in
sqlite3
CLI banner when running on Windows.gh-103636 [https://github.com/python/cpython/issues/103636]: Module-level attributes
January
andFebruary
are deprecated fromcalendar
.gh-103583 [https://github.com/python/cpython/issues/103583]: Isolate
_multibytecodec
and codecs extension modules. Patches by Erlend E. Aasland.gh-103848 [https://github.com/python/cpython/issues/103848]: Add checks to ensure that
[
bracketed]
hosts found byurllib.parse.urlsplit()
are of IPv6 or IPvFuture format.gh-103872 [https://github.com/python/cpython/issues/103872]: Update the bundled copy of pip to version 23.1.2.
gh-99944 [https://github.com/python/cpython/issues/99944]: Make
dis
display the value of oparg ofKW_NAMES
.gh-74940 [https://github.com/python/cpython/issues/74940]: The C.UTF-8 locale is no longer converted to en_US.UTF-8, enabling the use of UTF-8 encoding on systems which have no locales installed.
gh-103861 [https://github.com/python/cpython/issues/103861]: Fix
zipfile.Zipfile
creating invalid zip files whenforce_zip64
was used to add files to them. Patch by Carey Metcalfe.gh-103857 [https://github.com/python/cpython/issues/103857]: Deprecated
datetime.datetime.utcnow()
anddatetime.datetime.utcfromtimestamp()
. (Patch by Paul Ganssle)gh-103839 [https://github.com/python/cpython/issues/103839]: Avoid compilation error due to tommath.h not being found when building Tkinter against Tcl 8.7 built with bundled libtommath.
gh-103791 [https://github.com/python/cpython/issues/103791]:
contextlib.suppress
now supports suppressing exceptions raised as part of anExceptionGroup
. If other exceptions exist on the group, they are reraised in a group that does not contain the suppressed exceptions.gh-90750 [https://github.com/python/cpython/issues/90750]: Use
datetime.datetime.fromisocalendar()
in the implementation ofdatetime.datetime.strptime()
, which should now accept only valid ISO dates. (Patch by Paul Ganssle)gh-103685 [https://github.com/python/cpython/issues/103685]: Prepare
tkinter.Menu.index()
for Tk 8.7 so that it does not raiseTclError: expected integer but got ""
when it should returnNone
.gh-81403 [https://github.com/python/cpython/issues/81403]:
urllib.request.CacheFTPHandler
no longer raisesURLError
if a cached FTP instance is reused. ftplib's endtransfer method calls voidresp to drain the connection to handle FTP instance reuse properly.gh-103699 [https://github.com/python/cpython/issues/103699]: Add
__orig_bases__
to non-generic TypedDicts, call-based TypedDicts, and call-based NamedTuples. Other TypedDicts and NamedTuples already had the attribute.gh-103693 [https://github.com/python/cpython/issues/103693]: Add convenience variable feature to
pdb
gh-92248 [https://github.com/python/cpython/issues/92248]: Deprecate
type
,choices
, andmetavar
parameters ofargparse.BooleanOptionalAction
.gh-89415 [https://github.com/python/cpython/issues/89415]: Add
socket
constants for source-specific multicast. Patch by Reese Hyde.gh-103673 [https://github.com/python/cpython/issues/103673]:
socketserver
gainsForkingUnixStreamServer
andForkingUnixDatagramServer
classes. Patch by Jay Berry.gh-103636 [https://github.com/python/cpython/issues/103636]: Added Enum for months and days in the calendar module.
gh-84976 [https://github.com/python/cpython/issues/84976]: Create a new
Lib/_pydatetime.py
file that defines the Python version of thedatetime
module, and makedatetime
import the contents of the new library only if the C implementation is missing. Currently, the full Python implementation is defined and then deleted if the C implementation is not available, slowing downimport datetime
unnecessarily.gh-103596 [https://github.com/python/cpython/issues/103596]: Attributes/methods are no longer shadowed by same-named enum members, although they may be shadowed by enum.property's.
gh-103584 [https://github.com/python/cpython/issues/103584]: Updated
importlib.metadata
with changes fromimportlib_metadata
5.2 through 6.5.0, including: Supportinstalled-files.txt
forDistribution.files
when present.PackageMetadata
now stipulates an additionalget
method allowing for easy querying of metadata keys that may not be present.packages_distributions
now honors packages and modules with Python modules that not.py
sources (e.g..pyc
,.so
). Expand protocol forPackageMetadata.get_all
to match the upstream implementation ofemail.message.Message.get_all
in python/typeshed#9620. Deprecated use ofDistribution
without defining abstract methods. Deprecated expectation thatPackageMetadata.__getitem__
will returnNone
for missing keys. In the future, it will raise aKeyError
.gh-103578 [https://github.com/python/cpython/issues/103578]: Fixed a bug where
pdb
crashes when reading source file with different encoding by replacingio.open()
withio.open_code()
. The new method would also call into the hook set byPyFile_SetOpenCodeHook()
.gh-103556 [https://github.com/python/cpython/issues/103556]: Now creating
inspect.Signature
objects with positional-only parameter with a default followed by a positional-or-keyword parameter without one is impossible.gh-103559 [https://github.com/python/cpython/issues/103559]: Update the bundled copy of pip to version 23.1.1.
gh-103548 [https://github.com/python/cpython/issues/103548]: Improve performance of
pathlib.Path.absolute()
andcwd()
by joining paths only when necessary. Also improve performance ofpathlib.PurePath.is_absolute()
on Posix by skipping path parsing and normalization.gh-103538 [https://github.com/python/cpython/issues/103538]: Remove
_tkinter
module code guarded by definition of theTK_AQUA
macro which was only needed for Tk 8.4.7 or earlier and was never actually defined by any build system or documented for manual use.gh-103533 [https://github.com/python/cpython/issues/103533]: Update
cProfile
to use PEP 669 APIgh-103525 [https://github.com/python/cpython/issues/103525]: Fix misleading exception message when mixed
str
andbytes
arguments are supplied topathlib.PurePath
andPath
.gh-103489 [https://github.com/python/cpython/issues/103489]: Add
getconfig()
andsetconfig()
toConnection
to make configuration changes to a database connection. Patch by Erlend E. Aasland.gh-103365 [https://github.com/python/cpython/issues/103365]: Set default Flag boundary to
STRICT
and fix bitwise operations.gh-103472 [https://github.com/python/cpython/issues/103472]: Avoid a potential
ResourceWarning
inhttp.client.HTTPConnection
by closing the proxy / tunnel's CONNECT response explicitly.gh-103462 [https://github.com/python/cpython/issues/103462]: Fixed an issue with using
writelines()
inasyncio
to send very large payloads that exceed the amount of data that can be written in one call tosocket.socket.send()
orsocket.socket.sendmsg()
, resulting in the remaining buffer being left unwritten.gh-103449 [https://github.com/python/cpython/issues/103449]: Fix a bug in doc string generation in
dataclasses.dataclass()
.gh-103092 [https://github.com/python/cpython/issues/103092]: Isolate
_collections
(apply PEP 687 [https://peps.python.org/pep-0687/]). Patch by Erlend E. Aasland.gh-103357 [https://github.com/python/cpython/issues/103357]: Added support for
logging.Formatter
defaults
parameter tologging.config.dictConfig()
andlogging.config.fileConfig()
. Patch by Bar Harel.gh-103092 [https://github.com/python/cpython/issues/103092]: Adapt the
winreg
extension module to PEP 687 [https://peps.python.org/pep-0687/].gh-74690 [https://github.com/python/cpython/issues/74690]: The performance of
isinstance()
checks againstruntime-checkable protocols
has been considerably improved for protocols that only have a few members. To achieve this improvement, several internal implementation details of thetyping
module have been refactored, includingtyping._ProtocolMeta.__instancecheck__
,typing._is_callable_members_only
, andtyping.getprotocol_attrs
. Patches by Alex Waygood.gh-74690 [https://github.com/python/cpython/issues/74690]: The members of a runtime-checkable protocol are now considered "frozen" at runtime as soon as the class has been created. See "What's new in Python 3.12" for more details.
gh-103256 [https://github.com/python/cpython/issues/103256]: Fixed a bug that caused
hmac
to raise an exception when the requested hash algorithm was not available in OpenSSL despite being available separately as part ofhashlib
itself. It now falls back properly to the builtin. This could happen when, for example, your OpenSSL does not include SHA3 support and you want to computehmac.digest(b'K', b'M', 'sha3_256')
.gh-102778 [https://github.com/python/cpython/issues/102778]: Support
sys.last_exc
inidlelib
.gh-103285 [https://github.com/python/cpython/issues/103285]: Improve performance of
ast.get_source_segment()
.gh-103225 [https://github.com/python/cpython/issues/103225]: Fix a bug in
pdb
when displaying line numbers of module-level source code.gh-103092 [https://github.com/python/cpython/issues/103092]: Adapt the
msvcrt
extension module to PEP 687 [https://peps.python.org/pep-0687/].gh-103092 [https://github.com/python/cpython/issues/103092]: Adapt the
winsound
extension module to PEP 687 [https://peps.python.org/pep-0687/].gh-93910 [https://github.com/python/cpython/issues/93910]: Remove deprecation of enum
member.member
access.gh-102978 [https://github.com/python/cpython/issues/102978]: Fixes
unittest.mock.patch()
not enforcing function signatures for methods decorated with@classmethod
or@staticmethod
when patch is called withautospec=True
.gh-103092 [https://github.com/python/cpython/issues/103092]: Isolate
_socket
(apply PEP 687 [https://peps.python.org/pep-0687/]). Patch by Erlend E. Aasland.gh-100479 [https://github.com/python/cpython/issues/100479]: Add
pathlib.PurePath.with_segments()
, which creates a path object from arguments. This method is called whenever a derivative path is created, such as frompathlib.PurePath.parent
. Subclasses may override this method to share information between path objects.gh-103220 [https://github.com/python/cpython/issues/103220]: Fix issue where
os.path.join()
added a slash when joining onto an incomplete UNC drive with a trailing slash on Windows.gh-103204 [https://github.com/python/cpython/issues/103204]: Fixes
http.server
accepting HTTP requests with HTTP version numbers preceded by '+', or '-', or with digit-separating '_' characters. The length of the version numbers is also constrained.gh-75586 [https://github.com/python/cpython/issues/75586]: Fix various Windows-specific issues with
shutil.which
.gh-103193 [https://github.com/python/cpython/issues/103193]: Improve performance of
inspect.getattr_static()
. Patch by Alex Waygood.gh-103176 [https://github.com/python/cpython/issues/103176]:
sys._current_exceptions()
now returns a mapping from thread-id to an exception instance, rather than to a(typ, exc, tb)
tuple.gh-103143 [https://github.com/python/cpython/issues/103143]: Polish the help messages and docstrings of
pdb
.gh-103015 [https://github.com/python/cpython/issues/103015]: Add entrypoint keyword-only parameter to
sqlite3.Connection.load_extension()
, for overriding the SQLite extension entry point. Patch by Erlend E. Aasland.gh-103000 [https://github.com/python/cpython/issues/103000]: Improve performance of
dataclasses.astuple()
anddataclasses.asdict()
in cases where the contents are common Python types.gh-102953 [https://github.com/python/cpython/issues/102953]: The extraction methods in
tarfile
, andshutil.unpack_archive()
, have a new a filter argument that allows limiting tar features than may be surprising or dangerous, such as creating files outside the destination directory. See 解压缩过滤器 for details.gh-97696 [https://github.com/python/cpython/issues/97696]: Implemented an eager task factory in asyncio. When used as a task factory on an event loop, it performs eager execution of coroutines. Coroutines that are able to complete synchronously (e.g. return or raise without blocking) are returned immediately as a finished task, and the task is never scheduled to the event loop. If the coroutine blocks, the (pending) task is scheduled and returned.
gh-81079 [https://github.com/python/cpython/issues/81079]: Add case_sensitive keyword-only argument to
pathlib.Path.glob()
andrglob()
.gh-101819 [https://github.com/python/cpython/issues/101819]: Isolate the
io
extension module by applying PEP 687 [https://peps.python.org/pep-0687/]. Patch by Kumar Aditya, Victor Stinner, and Erlend E. Aasland.gh-91896 [https://github.com/python/cpython/issues/91896]: Deprecate
collections.abc.ByteString
gh-101362 [https://github.com/python/cpython/issues/101362]: Speed up
pathlib.Path
construction by omitting the path anchor from the internal list of path parts.gh-102114 [https://github.com/python/cpython/issues/102114]: Functions in the
dis
module that accept a source code string as argument now print a more concise traceback when the string contains a syntax or indentation error.gh-62432 [https://github.com/python/cpython/issues/62432]: The
unittest
runner will now exit with status code 5 if no tests were run. It is common for test runner misconfiguration to fail to find any tests, this should be an error.gh-78079 [https://github.com/python/cpython/issues/78079]: Fix incorrect normalization of UNC device path roots, and partial UNC share path roots, in
pathlib.PurePath
. Pathlib no longer appends a trailing slash to such paths.gh-85984 [https://github.com/python/cpython/issues/85984]: Add
tty.cfmakeraw()
andtty.cfmakecbreak()
totty
and modernize, the behavior oftty.setraw()
andtty.setcbreak()
to use POSIX.1-2017 Chapter 11 "General Terminal Interface" flag masks by default.gh-101688 [https://github.com/python/cpython/issues/101688]: Implement
types.get_original_bases()
to provide further introspection for types.gh-101640 [https://github.com/python/cpython/issues/101640]:
argparse.ArgumentParser
now catches errors when writing messages, such as whensys.stderr
isNone
. Patch by Oleg Iarygin.gh-83861 [https://github.com/python/cpython/issues/83861]: Fix datetime.astimezone method return value when invoked on a naive datetime instance that represents local time falling in a timezone transition gap. PEP 495 requires that instances with fold=1 produce earlier times than those with fold=0 in this case.
gh-89550 [https://github.com/python/cpython/issues/89550]: Decrease execution time of some
gzip
file writes by 15% by adding more appropriate buffering.gh-95299 [https://github.com/python/cpython/issues/95299]: Remove the bundled setuptools wheel from
ensurepip
, and stop installing setuptools in environments created byvenv
.gh-99353 [https://github.com/python/cpython/issues/99353]: Respect the
http.client.HTTPConnection
.debuglevel
flag inurllib.request.AbstractHTTPHandler
when its constructor parameterdebuglevel
is not set. And do the same forHTTPS
.gh-98040 [https://github.com/python/cpython/issues/98040]: Remove the long-deprecated
imp
module.gh-97850 [https://github.com/python/cpython/issues/97850]: Deprecate
pkgutil.find_loader()
andpkgutil.get_loader()
in favor ofimportlib.util.find_spec()
.gh-94473 [https://github.com/python/cpython/issues/94473]: Flatten arguments in
tkinter.Canvas.coords()
. It now accepts not onlyx1, y1, x2, y2, …
and[x1, y1, x2, y2, …]
, but also(x1, y1), (x2, y2), …
and[(x1, y1), (x2, y2), …]
.gh-98040 [https://github.com/python/cpython/issues/98040]: Remove more deprecated importlib APIs:
find_loader()
,find_module()
,importlib.abc.Finder
,pkgutil.ImpImporter
,pkgutil.ImpLoader
.gh-96522 [https://github.com/python/cpython/issues/96522]: Fix potential deadlock in pty.spawn()
gh-96534 [https://github.com/python/cpython/issues/96534]: Support divert(4) added in FreeBSD 14.
gh-87474 [https://github.com/python/cpython/issues/87474]: Fix potential file descriptor leaks in
subprocess.Popen
.gh-94906 [https://github.com/python/cpython/issues/94906]: Support multiple steps in
math.nextafter()
. Patch by Shantanu Jain and Matthias Gorgens.gh-51574 [https://github.com/python/cpython/issues/51574]: Make
tempfile.mkdtemp()
return absolute paths when its dir parameter is relative.gh-94518 [https://github.com/python/cpython/issues/94518]: Convert private
posixsubprocess.forkexec()
to use Argument Clinic.gh-92184 [https://github.com/python/cpython/issues/92184]: When creating zip files using
zipfile
,os.altsep
, if notNone
, will always be treated as a path separator even when it is not/
. Patch by Carey Metcalfe.bpo-46797 [https://bugs.python.org/issue?@action=redirect&bpo=46797]: Deprecation warnings are now emitted for
ast.Num
,ast.Bytes
,ast.Str
,ast.NameConstant
andast.Ellipsis
. These have been documented as deprecated since Python 3.8, and will be removed in Python 3.14.bpo-44844 [https://bugs.python.org/issue?@action=redirect&bpo=44844]: Enables
webbrowser
to detect and launch Microsoft Edge browser.bpo-45606 [https://bugs.python.org/issue?@action=redirect&bpo=45606]: Fixed the bug in
pathlib.Path.glob()
— previously a dangling symlink would not be found by this method when the pattern is an exact match, but would be found when the pattern contains a wildcard or the recursive wildcard (**
). With this change, a dangling symlink will be found in both cases.bpo-23041 [https://bugs.python.org/issue?@action=redirect&bpo=23041]: Add
QUOTE_STRINGS
andQUOTE_NOTNULL
to the suite ofcsv
module quoting styles.bpo-24964 [https://bugs.python.org/issue?@action=redirect&bpo=24964]: Added
http.client.HTTPConnection.get_proxy_response_headers()
that provides access to the HTTP headers on a proxy server response to theCONNECT
request.bpo-17258 [https://bugs.python.org/issue?@action=redirect&bpo=17258]:
multiprocessing
now supports stronger HMAC algorithms for interprocess connection authentication rather than only HMAC-MD5.bpo-39744 [https://bugs.python.org/issue?@action=redirect&bpo=39744]: Make
asyncio.subprocess.Process.communicate()
close the subprocess's stdin even when called withinput=None
.bpo-22708 [https://bugs.python.org/issue?@action=redirect&bpo=22708]: http.client CONNECT method tunnel improvements: Use HTTP 1.1 protocol; send a matching Host: header with CONNECT, if one is not provided; convert IDN domain names to Punycode. Patch by Michael Handler.
文档
gh-67056 [https://github.com/python/cpython/issues/67056]: Document that the effect of registering or unregistering an
atexit
cleanup function from within a registered cleanup function is undefined.gh-103629 [https://github.com/python/cpython/issues/103629]: Mention the new way of typing
**kwargs
withUnpack
andTypedDict
introduced in PEP 692 [https://peps.python.org/pep-0692/].gh-48241 [https://github.com/python/cpython/issues/48241]: Clarifying documentation about the url parameter to urllib.request.urlopen and urllib.request.Request needing to be encoded properly.
gh-86094 [https://github.com/python/cpython/issues/86094]: Add support for Unicode Path Extra Field in ZipFile. Patch by Yeojin Kim and Andrea Giudiceandrea
gh-99202 [https://github.com/python/cpython/issues/99202]: Fix extension type from documentation for compiling in C++20 mode
测试
gh-104494 [https://github.com/python/cpython/issues/104494]: Update
test_pack_configure_in
andtest_place_configure_in
for changes to error message formatting in Tk 8.7.gh-104461 [https://github.com/python/cpython/issues/104461]: Run test_configure_screen on X11 only, since the
DISPLAY
environment variable and-screen
option for toplevels are not useful on Tk for Win32 or Aqua.gh-86275 [https://github.com/python/cpython/issues/86275]: Added property-based tests to the
zoneinfo
tests, along with stubs for thehypothesis
interface. (Patch by Paul Ganssle)gh-103329 [https://github.com/python/cpython/issues/103329]: Regression tests for the behaviour of
unittest.mock.PropertyMock
were added.gh-102795 [https://github.com/python/cpython/issues/102795]: fix use of poll in test_epoll's test_control_and_wait
gh-75729 [https://github.com/python/cpython/issues/75729]: Fix the
os.spawn*
tests failing on Windows when the working directory or interpreter path contains spaces.
构建
gh-101282 [https://github.com/python/cpython/issues/101282]: BOLT optimization is now applied to the libpython shared library if building a shared library. BOLT instrumentation and application settings can now be influenced via the
BOLT_INSTRUMENT_FLAGS
andBOLT_APPLY_FLAGS
configure variables.gh-99017 [https://github.com/python/cpython/issues/99017]:
PYTHON_FOR_REGEN
now require Python 3.10 or newer.gh-104490 [https://github.com/python/cpython/issues/104490]: Define
.PHONY
/ virtual make targets consistently and properly.gh-104106 [https://github.com/python/cpython/issues/104106]: Add gcc fallback of mkfifoat/mknodat for macOS. Patch by Donghee Na.
gh-103532 [https://github.com/python/cpython/issues/103532]: The
TKINTER_PROTECT_LOADTK
macro is no longer defined or used in the_tkinter
module. It was previously only defined when building against Tk 8.4.13 and older, but Tk older than 8.5.12 has been unsupported since gh-91152 [https://github.com/python/cpython/issues/91152].gh-99069 [https://github.com/python/cpython/issues/99069]: Extended workaround defining
static_assert
when missing from the libc headers to all clang and gcc builds. In particular, this fixes building on macOS <= 10.10.gh-100220 [https://github.com/python/cpython/issues/100220]: Changed the default value of the
SHELL
Makefile variable frombinsh
tobinsh -e
to ensure that complex recipes correctly fail after an error. Previously,make install
could fail to install some files and yet return a successful result.gh-90656 [https://github.com/python/cpython/issues/90656]: Add platform triplets for 64-bit LoongArch:
loongarch64-linux-gnusf
loongarch64-linux-gnuf32
loongarch64-linux-gnu
Patch by Zhang Na.
Windows
gh-104623 [https://github.com/python/cpython/issues/104623]: Update Windows installer to use SQLite 3.42.0.
gh-82814 [https://github.com/python/cpython/issues/82814]: Fix a potential
[Errno 13] Permission denied
when usingshutil.copystat()
within Windows Subsystem for Linux (WSL) on a mounted filesystem by addingerrno.EACCES
to the list of ignored errors within the internal implementation.gh-103088 [https://github.com/python/cpython/issues/103088]: Fix virtual environment
activate
script having incorrect line endings for Cygwin.gh-103088 [https://github.com/python/cpython/issues/103088]: Fixes venvs not working in bash on Windows across different disks
gh-102997 [https://github.com/python/cpython/issues/102997]: Update Windows installer to use SQLite 3.41.2.
gh-88013 [https://github.com/python/cpython/issues/88013]: Fixed a bug where
TypeError
was raised when callingntpath.realpath()
with a bytes parameter in some cases.
macOS
gh-99834 [https://github.com/python/cpython/issues/99834]: Update macOS installer to Tcl/Tk 8.6.13.
gh-104623 [https://github.com/python/cpython/issues/104623]: Update macOS installer to SQLite 3.42.0.
gh-103545 [https://github.com/python/cpython/issues/103545]: Add
os.PRIO_DARWIN_THREAD
,os.PRIO_DARWIN_PROCESS
,os.PRIO_DARWIN_BG
andos.PRIO_DARWIN_NONUI
. These can be used withos.setpriority
to run the process at a lower priority and make use of the efficiency cores on Apple Silicon systems.gh-104180 [https://github.com/python/cpython/issues/104180]: Support reading SOCKS proxy configuration from macOS System Configuration. Patch by Sam Schott.
gh-60436 [https://github.com/python/cpython/issues/60436]: update curses textbox to additionally handle backspace using the
curses.ascii.DEL
key press.gh-102997 [https://github.com/python/cpython/issues/102997]: Update macOS installer to SQLite 3.41.2.
IDLE
gh-104499 [https://github.com/python/cpython/issues/104499]: Fix completions for Tk Aqua 8.7 (currently blank).
gh-104496 [https://github.com/python/cpython/issues/104496]: About prints both tcl and tk versions if different (expected someday).
gh-88496 [https://github.com/python/cpython/issues/88496]: Fix IDLE test hang on macOS.
工具/示例
- gh-104389 [https://github.com/python/cpython/issues/104389]: Argument Clinic C converters now accept the
unused
keyword, for wrapping a parameter withPy_UNUSED
. Patch by Erlend E. Aasland.
C API
gh-101291 [https://github.com/python/cpython/issues/101291]: Added unstable C API for extracting the value of "compact" integers:
PyUnstable_Long_IsCompact()
andPyUnstable_Long_CompactValue()
.gh-104109 [https://github.com/python/cpython/issues/104109]: We've added
Py_NewInterpreterFromConfig()
andPyInterpreterConfig
to the public C-API (but not the stable ABI; not yet at least). The new function may be used to create a new interpreter with various features configured. The function was added to support PEP 684 (per-interpreter GIL).gh-103968 [https://github.com/python/cpython/issues/103968]:
PyType_FromSpec()
and its variants now allow creating classes whose metaclass overridestp_new
. Thetp_new
is ignored. This behavior is deprecated and will be disallowed in 3.14+. The newPyType_FromMetaclass()
already disallows it.gh-103743 [https://github.com/python/cpython/issues/103743]: Add
PyUnstable_Object_GC_NewWithExtraData()
function that can be used to allocate additional memory after an object for data not managed by Python.gh-103295 [https://github.com/python/cpython/issues/103295]: Introduced
PyUnstable_WritePerfMapEntry()
,PyUnstable_PerfMapState_Init()
andPyUnstable_PerfMapState_Fini()
. These allow extension modules (JIT compilers in particular) to write to perfmap files in a thread safe manner. The Python 对 Linux perf 性能分析器的支持 also uses these APIs to write entries in the perfmap file.gh-103509 [https://github.com/python/cpython/issues/103509]: Added C API for extending types whose instance memory layout is opaque:
PyType_Spec.basicsize
can now be zero or negative,PyObject_GetTypeData()
can be used to get subclass-specific data, andPy_TPFLAGS_ITEMS_AT_END
can be used to safely extend variable-size objects. See PEP 697 [https://peps.python.org/pep-0697/] for details.gh-103091 [https://github.com/python/cpython/issues/103091]: Add a new C-API function to eagerly assign a version tag to a PyTypeObject:
PyUnstable_Type_AssignVersionTag()
.gh-101408 [https://github.com/python/cpython/issues/101408]:
PyObject_GC_Resize
should calculate preheader size if needed. Patch by Donghee Na.gh-98836 [https://github.com/python/cpython/issues/98836]: Add support of more formatting options (left aligning, octals, uppercase hexadecimals,
intmax_t
,ptrdiff_t
,wchar_t
C strings, variable width and precision) inPyUnicode_FromFormat()
andPyUnicode_FromFormatV()
.gh-96803 [https://github.com/python/cpython/issues/96803]: Add unstable C-API functions to get the code object, lasti and line number from the internal
_PyInterpreterFrame
in the limited API. The functions are:PyCodeObject * PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame)
int PyUnstable_InterpreterFrame_GetLasti(struct _PyInterpreterFrame *frame)
int PyUnstable_InterpreterFrame_GetLine(struct _PyInterpreterFrame *frame)
Python 3.12.0 alpha 7
Release date: 2023-04-04