diff --git a/Doc/bugs.rst b/Doc/bugs.rst index 0683eebbaf677b..254a22f2622bd8 100644 --- a/Doc/bugs.rst +++ b/Doc/bugs.rst @@ -9,7 +9,7 @@ stability. In order to maintain this reputation, the developers would like to know of any deficiencies you find in Python. It can be sometimes faster to fix bugs yourself and contribute patches to -Python as it streamlines the process and involves less people. Learn how to +Python as it streamlines the process and involves fewer people. Learn how to :ref:`contribute `. Documentation bugs diff --git a/Doc/c-api/float.rst b/Doc/c-api/float.rst index b0d440580b9886..dcd545478277a8 100644 --- a/Doc/c-api/float.rst +++ b/Doc/c-api/float.rst @@ -80,7 +80,7 @@ Floating-Point Objects .. c:macro:: Py_INFINITY - This macro expands a to constant expression of type :c:expr:`double`, that + This macro expands to a constant expression of type :c:expr:`double`, that represents the positive infinity. It is equivalent to the :c:macro:`!INFINITY` macro from the C11 standard @@ -92,7 +92,7 @@ Floating-Point Objects .. c:macro:: Py_NAN - This macro expands a to constant expression of type :c:expr:`double`, that + This macro expands to a constant expression of type :c:expr:`double`, that represents a quiet not-a-number (qNaN) value. On most platforms, this is equivalent to the :c:macro:`!NAN` macro from diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 7411644f9e110b..6786aa76563f52 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -424,7 +424,7 @@ Initializing and finalizing the interpreter Note that Python will do a best effort at freeing all memory allocated by the Python interpreter. Therefore, any C-Extension should make sure to correctly clean up all - of the preveiously allocated PyObjects before using them in subsequent calls to + of the previously allocated PyObjects before using them in subsequent calls to :c:func:`Py_Initialize`. Otherwise it could introduce vulnerabilities and incorrect behavior. @@ -1407,7 +1407,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`. Get the current interpreter. - Issue a fatal error if there no :term:`attached thread state`. + Issue a fatal error if there is no :term:`attached thread state`. It cannot return NULL. .. versionadded:: 3.9 @@ -1979,7 +1979,7 @@ Python-level trace functions in previous versions. *what* when after any bytecode is processed after which the exception becomes set within the frame being executed. The effect of this is that as exception propagation causes the Python stack to unwind, the callback is called upon - return to each frame as the exception propagates. Only trace functions receives + return to each frame as the exception propagates. Only trace functions receive these events; they are not needed by the profiler. @@ -2119,7 +2119,7 @@ Reference tracing the tracer function is called. Return ``0`` on success. Set an exception and return ``-1`` on error. - Not that tracer functions **must not** create Python objects inside or + Note that tracer functions **must not** create Python objects inside or otherwise the call will be re-entrant. The tracer also **must not** clear any existing exception or set an exception. A :term:`thread state` will be active every time the tracer function is called. diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst index c345029e4acd49..a143274bfe69e2 100644 --- a/Doc/c-api/init_config.rst +++ b/Doc/c-api/init_config.rst @@ -544,9 +544,9 @@ Configuration Options Visibility: -* Public: Can by get by :c:func:`PyConfig_Get` and set by +* Public: Can be retrieved by :c:func:`PyConfig_Get` and set by :c:func:`PyConfig_Set`. -* Read-only: Can by get by :c:func:`PyConfig_Get`, but cannot be set by +* Read-only: Can be retrieved by :c:func:`PyConfig_Get`, but cannot be set by :c:func:`PyConfig_Set`. @@ -1153,7 +1153,7 @@ PyConfig Most ``PyConfig`` methods :ref:`preinitialize Python ` if needed. In that case, the Python preinitialization configuration - (:c:type:`PyPreConfig`) in based on the :c:type:`PyConfig`. If configuration + (:c:type:`PyPreConfig`) is based on the :c:type:`PyConfig`. If configuration fields which are in common with :c:type:`PyPreConfig` are tuned, they must be set before calling a :c:type:`PyConfig` method: diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst index e7ea5b9ba4016c..a5dfbe7f4e1305 100644 --- a/Doc/c-api/intro.rst +++ b/Doc/c-api/intro.rst @@ -220,7 +220,7 @@ Docstring macros General utility macros ---------------------- -The following macros common tasks not specific to Python. +The following macros are for common tasks not specific to Python. .. c:macro:: Py_UNUSED(arg) @@ -317,7 +317,7 @@ Assertion utilities In debug mode, and on unsupported compilers, the macro expands to a call to :c:func:`Py_FatalError`. - A use for ``Py_UNREACHABLE()`` is following a call a function that + A use for ``Py_UNREACHABLE()`` is following a call to a function that never returns but that is not declared ``_Noreturn``. If a code path is very unlikely code but can be reached under exceptional diff --git a/Doc/c-api/module.rst b/Doc/c-api/module.rst index 5c8b0511492c1e..aa2145b5fe5d09 100644 --- a/Doc/c-api/module.rst +++ b/Doc/c-api/module.rst @@ -752,7 +752,7 @@ remove it. .. versionchanged:: 3.9 :c:member:`m_traverse`, :c:member:`m_clear` and :c:member:`m_free` - functions are longer called before the module state is allocated. + functions are no longer called before the module state is allocated. .. _moduledef-dynamic: diff --git a/Doc/c-api/object.rst b/Doc/c-api/object.rst index 992a4383f97241..f71bfebdb2a19a 100644 --- a/Doc/c-api/object.rst +++ b/Doc/c-api/object.rst @@ -801,3 +801,20 @@ Object Protocol cannot fail. .. versionadded:: 3.14 + +.. c:function:: int PyUnstable_SetImmortal(PyObject *op) + + Marks the object *op* :term:`immortal`. The argument should be uniquely referenced by + the calling thread. This is intended to be used for reducing reference counting contention + in the :term:`free-threaded build` for objects which are shared across threads. + + This is a one-way process: objects can only be made immortal; they cannot be + made mortal once again. Immortal objects do not participate in reference counting + and will never be garbage collected. If the object is GC-tracked, it is untracked. + + This function is intended to be used soon after *op* is created, by the code that + creates it, such as in the object's :c:member:`~PyTypeObject.tp_new` slot. + Returns 1 if the object was made immortal and returns 0 if it was not. + This function cannot fail. + + .. versionadded:: next diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index 62f45def04f746..70c4de543b7d00 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -410,7 +410,7 @@ There are these calling conventions: These two constants are not used to indicate the calling convention but the -binding when use with methods of classes. These may not be used for functions +binding when used with methods of classes. These may not be used for functions defined for modules. At most one of these flags may be set for any given method. diff --git a/Doc/c-api/veryhigh.rst b/Doc/c-api/veryhigh.rst index 7eb9f0b54abd4e..6256bf7a1454a9 100644 --- a/Doc/c-api/veryhigh.rst +++ b/Doc/c-api/veryhigh.rst @@ -191,7 +191,7 @@ the same library that the Python runtime is using. objects *globals* and *locals* with the compiler flags specified by *flags*. *globals* must be a dictionary; *locals* can be any object that implements the mapping protocol. The parameter *start* specifies - the start symbol and must one of the :ref:`available start symbols `. + the start symbol and must be one of the :ref:`available start symbols `. Returns the result of executing the code as a Python object, or ``NULL`` if an exception was raised. diff --git a/Doc/deprecations/pending-removal-in-3.15.rst b/Doc/deprecations/pending-removal-in-3.15.rst index 00266b1725c8a1..e7f27f73664df3 100644 --- a/Doc/deprecations/pending-removal-in-3.15.rst +++ b/Doc/deprecations/pending-removal-in-3.15.rst @@ -54,7 +54,7 @@ Pending removal in Python 3.15 * :func:`~threading.RLock` will take no arguments in Python 3.15. Passing any arguments has been deprecated since Python 3.14, - as the Python version does not permit any arguments, + as the Python version does not permit any arguments, but the C version allows any number of positional or keyword arguments, ignoring every argument. diff --git a/Doc/glossary.rst b/Doc/glossary.rst index 24b95b88dfb651..6151143a97b420 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -951,6 +951,16 @@ Glossary to locks exist such as queues, producer/consumer patterns, and thread-local state. See also :term:`deadlock`, and :term:`reentrant`. + lock-free + An operation that does not acquire any :term:`lock` and uses atomic CPU + instructions to ensure correctness. Lock-free operations can execute + concurrently without blocking each other and cannot be blocked by + operations that hold locks. In :term:`free-threaded ` + Python, built-in types like :class:`dict` and :class:`list` provide + lock-free read operations, which means other threads may observe + intermediate states during multi-step modifications even when those + modifications hold the :term:`per-object lock`. + loader An object that loads a module. It must define the :meth:`!exec_module` and :meth:`!create_module` methods @@ -1217,6 +1227,16 @@ Glossary `, the :class:`inspect.Parameter` class, the :ref:`function` section, and :pep:`362`. + per-object lock + A :term:`lock` associated with an individual object instance rather than + a global lock shared across all objects. In :term:`free-threaded + ` Python, built-in types like :class:`dict` and + :class:`list` use per-object locks to allow concurrent operations on + different objects while serializing operations on the same object. + Operations that hold the per-object lock prevent other locking operations + on the same object from proceeding, but do not block :term:`lock-free` + operations. + path entry A single location on the :term:`import path` which the :term:`path based finder` consults to find modules for importing. @@ -1339,7 +1359,7 @@ Glossary 'email.mime.text' race condition - A condition of a program where the its behavior + A condition of a program where the behavior depends on the relative timing or ordering of events, particularly in multi-threaded programs. Race conditions can lead to :term:`non-deterministic` behavior and bugs that are difficult to diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst index 975c488813722e..771628677c3d98 100644 --- a/Doc/library/base64.rst +++ b/Doc/library/base64.rst @@ -105,10 +105,10 @@ POST request. For more information about the strict base64 check, see :func:`binascii.a2b_base64` - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *ignorechars* parameter. - .. deprecated:: next + .. deprecated:: 3.15 Accepting the ``+`` and ``/`` characters with an alternative alphabet is now deprecated. @@ -142,7 +142,7 @@ POST request. ``/`` in the standard Base64 alphabet, and return the decoded :class:`bytes`. - .. deprecated:: next + .. deprecated:: 3.15 Accepting the ``+`` and ``/`` characters is now deprecated. diff --git a/Doc/library/binascii.rst b/Doc/library/binascii.rst index 39320da93a8ad7..8a241e51ebfee6 100644 --- a/Doc/library/binascii.rst +++ b/Doc/library/binascii.rst @@ -75,7 +75,7 @@ The :mod:`!binascii` module defines the following functions: .. versionchanged:: 3.11 Added the *strict_mode* parameter. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *ignorechars* parameter. @@ -122,7 +122,7 @@ The :mod:`!binascii` module defines the following functions: Invalid Ascii85 data will raise :exc:`binascii.Error`. - .. versionadded:: next + .. versionadded:: 3.15 .. function:: b2a_ascii85(data, /, *, foldspaces=False, wrapcol=0, pad=False, adobe=False) @@ -145,7 +145,7 @@ The :mod:`!binascii` module defines the following functions: *adobe* controls whether the encoded byte sequence is framed with ``<~`` and ``~>``, which is used by the Adobe implementation. - .. versionadded:: next + .. versionadded:: 3.15 .. function:: a2b_base85(string, /) @@ -160,7 +160,7 @@ The :mod:`!binascii` module defines the following functions: Invalid Base85 data will raise :exc:`binascii.Error`. - .. versionadded:: next + .. versionadded:: 3.15 .. function:: b2a_base85(data, /, *, pad=False) @@ -171,7 +171,7 @@ The :mod:`!binascii` module defines the following functions: If *pad* is true, the input is padded with ``b'\0'`` so its length is a multiple of 4 bytes before encoding. - .. versionadded:: next + .. versionadded:: 3.15 .. function:: a2b_z85(string, /) @@ -188,7 +188,7 @@ The :mod:`!binascii` module defines the following functions: Invalid Z85 data will raise :exc:`binascii.Error`. - .. versionadded:: next + .. versionadded:: 3.15 .. function:: b2a_z85(data, /, *, pad=False) @@ -201,7 +201,7 @@ The :mod:`!binascii` module defines the following functions: See `Z85 specification `_ for more information. - .. versionadded:: next + .. versionadded:: 3.15 .. function:: a2b_qp(data, header=False) diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 9f958ee98c6119..36f5e94b8477ec 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -1551,8 +1551,8 @@ mapping. It is not supported by :meth:`str.encode` (which only produces Restoration of the ``rot13`` alias. -:mod:`encodings` --- Encodings package --------------------------------------- +:mod:`!encodings` --- Encodings package +--------------------------------------- .. module:: encodings :synopsis: Encodings package @@ -1611,8 +1611,8 @@ This module implements the following exception: Raised when a codec is invalid or incompatible. -:mod:`encodings.idna` --- Internationalized Domain Names in Applications ------------------------------------------------------------------------- +:mod:`!encodings.idna` --- Internationalized Domain Names in Applications +------------------------------------------------------------------------- .. module:: encodings.idna :synopsis: Internationalized Domain Names implementation @@ -1654,7 +1654,7 @@ When receiving host names from the wire (such as in reverse name lookup), no automatic conversion to Unicode is performed: applications wishing to present such host names to the user should decode them to Unicode. -The module :mod:`encodings.idna` also implements the nameprep procedure, which +The module :mod:`!encodings.idna` also implements the nameprep procedure, which performs certain normalizations on host names, to achieve case-insensitivity of international domain names, and to unify similar characters. The nameprep functions can be used directly if desired. @@ -1677,8 +1677,8 @@ functions can be used directly if desired. Convert a label to Unicode, as specified in :rfc:`3490`. -:mod:`encodings.mbcs` --- Windows ANSI codepage ------------------------------------------------ +:mod:`!encodings.mbcs` --- Windows ANSI codepage +------------------------------------------------ .. module:: encodings.mbcs :synopsis: Windows ANSI codepage @@ -1695,8 +1695,8 @@ This module implements the ANSI codepage (CP_ACP). Support any error handler. -:mod:`encodings.utf_8_sig` --- UTF-8 codec with BOM signature -------------------------------------------------------------- +:mod:`!encodings.utf_8_sig` --- UTF-8 codec with BOM signature +-------------------------------------------------------------- .. module:: encodings.utf_8_sig :synopsis: UTF-8 codec with BOM signature diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst index 564c11d0596c44..eec9ed1ba2581e 100644 --- a/Doc/library/contextlib.rst +++ b/Doc/library/contextlib.rst @@ -564,7 +564,7 @@ Functions and classes provided: Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm* is not a context manager. - .. versionchanged:: next + .. versionchanged:: 3.15 Added support for arbitrary descriptors :meth:`!__enter__` and :meth:`!__exit__`. @@ -586,7 +586,7 @@ Functions and classes provided: The passed in object is returned from the function, allowing this method to be used as a function decorator. - .. versionchanged:: next + .. versionchanged:: 3.15 Added support for arbitrary descriptors :meth:`!__exit__`. .. method:: callback(callback, /, *args, **kwds) @@ -646,7 +646,7 @@ Functions and classes provided: Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm* is not an asynchronous context manager. - .. versionchanged:: next + .. versionchanged:: 3.15 Added support for arbitrary descriptors :meth:`!__aenter__` and :meth:`!__aexit__`. .. method:: push_async_exit(exit) @@ -654,7 +654,7 @@ Functions and classes provided: Similar to :meth:`ExitStack.push` but expects either an asynchronous context manager or a coroutine function. - .. versionchanged:: next + .. versionchanged:: 3.15 Added support for arbitrary descriptors :meth:`!__aexit__`. .. method:: push_async_callback(callback, /, *args, **kwds) diff --git a/Doc/library/curses.rst b/Doc/library/curses.rst index 397584e70bf4ce..84efc6654e87c6 100644 --- a/Doc/library/curses.rst +++ b/Doc/library/curses.rst @@ -1824,8 +1824,8 @@ The following table lists the predefined colors: +-------------------------+----------------------------+ -:mod:`curses.textpad` --- Text input widget for curses programs -=============================================================== +:mod:`!curses.textpad` --- Text input widget for curses programs +================================================================ .. module:: curses.textpad :synopsis: Emacs-like input editing in a curses window. @@ -1833,13 +1833,13 @@ The following table lists the predefined colors: .. sectionauthor:: Eric Raymond -The :mod:`curses.textpad` module provides a :class:`Textbox` class that handles +The :mod:`!curses.textpad` module provides a :class:`Textbox` class that handles elementary text editing in a curses window, supporting a set of keybindings resembling those of Emacs (thus, also of Netscape Navigator, BBedit 6.x, FrameMaker, and many other programs). The module also provides a rectangle-drawing function useful for framing text boxes or for other purposes. -The module :mod:`curses.textpad` defines the following function: +The module :mod:`!curses.textpad` defines the following function: .. function:: rectangle(win, uly, ulx, lry, lrx) diff --git a/Doc/library/dbm.rst b/Doc/library/dbm.rst index 64201af2d22a58..2481d77f5fbfba 100644 --- a/Doc/library/dbm.rst +++ b/Doc/library/dbm.rst @@ -157,8 +157,8 @@ then prints out the contents of the database:: The individual submodules are described in the following sections. -:mod:`dbm.sqlite3` --- SQLite backend for dbm ---------------------------------------------- +:mod:`!dbm.sqlite3` --- SQLite backend for dbm +---------------------------------------------- .. module:: dbm.sqlite3 :platform: All @@ -172,7 +172,7 @@ The individual submodules are described in the following sections. This module uses the standard library :mod:`sqlite3` module to provide an SQLite backend for the :mod:`!dbm` module. -The files created by :mod:`dbm.sqlite3` can thus be opened by :mod:`sqlite3`, +The files created by :mod:`!dbm.sqlite3` can thus be opened by :mod:`sqlite3`, or any other SQLite browser, including the SQLite CLI. .. include:: ../includes/wasm-notavail.rst @@ -220,8 +220,8 @@ or any other SQLite browser, including the SQLite CLI. .. versionadded:: 3.15 -:mod:`dbm.gnu` --- GNU database manager ---------------------------------------- +:mod:`!dbm.gnu` --- GNU database manager +---------------------------------------- .. module:: dbm.gnu :platform: Unix @@ -231,20 +231,20 @@ or any other SQLite browser, including the SQLite CLI. -------------- -The :mod:`dbm.gnu` module provides an interface to the :abbr:`GDBM (GNU dbm)` +The :mod:`!dbm.gnu` module provides an interface to the :abbr:`GDBM (GNU dbm)` library, similar to the :mod:`dbm.ndbm` module, but with additional functionality like crash tolerance. .. note:: - The file formats created by :mod:`dbm.gnu` and :mod:`dbm.ndbm` are incompatible + The file formats created by :mod:`!dbm.gnu` and :mod:`dbm.ndbm` are incompatible and can not be used interchangeably. .. include:: ../includes/wasm-mobile-notavail.rst .. exception:: error - Raised on :mod:`dbm.gnu`-specific errors, such as I/O errors. :exc:`KeyError` is + Raised on :mod:`!dbm.gnu`-specific errors, such as I/O errors. :exc:`KeyError` is raised for general mapping errors like specifying an incorrect key. @@ -343,8 +343,8 @@ functionality like crash tolerance. unwritten data to be written to the disk. -:mod:`dbm.ndbm` --- New Database Manager ----------------------------------------- +:mod:`!dbm.ndbm` --- New Database Manager +----------------------------------------- .. module:: dbm.ndbm :platform: Unix @@ -354,14 +354,14 @@ functionality like crash tolerance. -------------- -The :mod:`dbm.ndbm` module provides an interface to the +The :mod:`!dbm.ndbm` module provides an interface to the :abbr:`NDBM (New Database Manager)` library. This module can be used with the "classic" NDBM interface or the :abbr:`GDBM (GNU dbm)` compatibility interface. .. note:: - The file formats created by :mod:`dbm.gnu` and :mod:`dbm.ndbm` are incompatible + The file formats created by :mod:`dbm.gnu` and :mod:`!dbm.ndbm` are incompatible and can not be used interchangeably. .. warning:: @@ -375,7 +375,7 @@ This module can be used with the "classic" NDBM interface or the .. exception:: error - Raised on :mod:`dbm.ndbm`-specific errors, such as I/O errors. :exc:`KeyError` is raised + Raised on :mod:`!dbm.ndbm`-specific errors, such as I/O errors. :exc:`KeyError` is raised for general mapping errors like specifying an incorrect key. @@ -425,8 +425,8 @@ This module can be used with the "classic" NDBM interface or the Close the NDBM database. -:mod:`dbm.dumb` --- Portable DBM implementation ------------------------------------------------ +:mod:`!dbm.dumb` --- Portable DBM implementation +------------------------------------------------ .. module:: dbm.dumb :synopsis: Portable implementation of the simple DBM interface. @@ -437,14 +437,14 @@ This module can be used with the "classic" NDBM interface or the .. note:: - The :mod:`dbm.dumb` module is intended as a last resort fallback for the - :mod:`!dbm` module when a more robust module is not available. The :mod:`dbm.dumb` + The :mod:`!dbm.dumb` module is intended as a last resort fallback for the + :mod:`!dbm` module when a more robust module is not available. The :mod:`!dbm.dumb` module is not written for speed and is not nearly as heavily used as the other database modules. -------------- -The :mod:`dbm.dumb` module provides a persistent :class:`dict`-like +The :mod:`!dbm.dumb` module provides a persistent :class:`dict`-like interface which is written entirely in Python. Unlike other :mod:`!dbm` backends, such as :mod:`dbm.gnu`, no external library is required. @@ -453,7 +453,7 @@ The :mod:`!dbm.dumb` module defines the following: .. exception:: error - Raised on :mod:`dbm.dumb`-specific errors, such as I/O errors. :exc:`KeyError` is + Raised on :mod:`!dbm.dumb`-specific errors, such as I/O errors. :exc:`KeyError` is raised for general mapping errors like specifying an incorrect key. @@ -484,7 +484,7 @@ The :mod:`!dbm.dumb` module defines the following: Python's AST compiler. .. warning:: - :mod:`dbm.dumb` does not support concurrent read/write access. (Multiple + :mod:`!dbm.dumb` does not support concurrent read/write access. (Multiple simultaneous read accesses are safe.) When a program has the database open for writing, no other program should have it open for reading or writing. diff --git a/Doc/library/dialog.rst b/Doc/library/dialog.rst index e0693e8eb6ed22..6fee23e942183d 100644 --- a/Doc/library/dialog.rst +++ b/Doc/library/dialog.rst @@ -1,8 +1,8 @@ Tkinter Dialogs =============== -:mod:`tkinter.simpledialog` --- Standard Tkinter input dialogs -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +:mod:`!tkinter.simpledialog` --- Standard Tkinter input dialogs +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. module:: tkinter.simpledialog :platform: Tk @@ -12,7 +12,7 @@ Tkinter Dialogs -------------- -The :mod:`tkinter.simpledialog` module contains convenience classes and +The :mod:`!tkinter.simpledialog` module contains convenience classes and functions for creating simple modal dialogs to get a value from the user. @@ -39,8 +39,8 @@ functions for creating simple modal dialogs to get a value from the user. -:mod:`tkinter.filedialog` --- File selection dialogs -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +:mod:`!tkinter.filedialog` --- File selection dialogs +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. module:: tkinter.filedialog :platform: Tk @@ -50,7 +50,7 @@ functions for creating simple modal dialogs to get a value from the user. -------------- -The :mod:`tkinter.filedialog` module provides classes and factory functions for +The :mod:`!tkinter.filedialog` module provides classes and factory functions for creating file/directory selection windows. Native Load/Save Dialogs @@ -204,8 +204,8 @@ These do not emulate the native look-and-feel of the platform. directory. Confirmation is required if an already existing file is selected. -:mod:`tkinter.commondialog` --- Dialog window templates -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +:mod:`!tkinter.commondialog` --- Dialog window templates +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. module:: tkinter.commondialog :platform: Tk @@ -215,7 +215,7 @@ These do not emulate the native look-and-feel of the platform. -------------- -The :mod:`tkinter.commondialog` module provides the :class:`Dialog` class that +The :mod:`!tkinter.commondialog` module provides the :class:`Dialog` class that is the base class for dialogs defined in other supporting modules. .. class:: Dialog(master=None, **options) diff --git a/Doc/library/email.encoders.rst b/Doc/library/email.encoders.rst index 9c8c8c9234ed7a..1a9a1cad3a619e 100644 --- a/Doc/library/email.encoders.rst +++ b/Doc/library/email.encoders.rst @@ -25,7 +25,7 @@ is especially true for :mimetype:`image/\*` and :mimetype:`text/\*` type message containing binary data. The :mod:`email` package provides some convenient encoders in its -:mod:`~email.encoders` module. These encoders are actually used by the +:mod:`!encoders` module. These encoders are actually used by the :class:`~email.mime.audio.MIMEAudio` and :class:`~email.mime.image.MIMEImage` class constructors to provide default encodings. All encoder functions take exactly one argument, the message object to encode. They usually extract the diff --git a/Doc/library/email.policy.rst b/Doc/library/email.policy.rst index 1ff3e2c3f8df6b..fef064114ecf1b 100644 --- a/Doc/library/email.policy.rst +++ b/Doc/library/email.policy.rst @@ -602,7 +602,7 @@ The header objects and their attributes are described in This concrete :class:`Policy` is the backward compatibility policy. It replicates the behavior of the email package in Python 3.2. The - :mod:`~email.policy` module also defines an instance of this class, + :mod:`!policy` module also defines an instance of this class, :const:`compat32`, that is used as the default policy. Thus the default behavior of the email package is to maintain compatibility with Python 3.2. diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index b2151f4d760927..5f0858cb134ebf 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -215,8 +215,8 @@ Functions in unexpected behavior. It's recommended to use the :class:`threading.Lock` or other synchronization primitives for thread-safe module reloading. -:mod:`importlib.abc` -- Abstract base classes related to import ---------------------------------------------------------------- +:mod:`!importlib.abc` -- Abstract base classes related to import +---------------------------------------------------------------- .. module:: importlib.abc :synopsis: Abstract base classes related to import @@ -226,7 +226,7 @@ Functions -------------- -The :mod:`importlib.abc` module contains all of the core abstract base classes +The :mod:`!importlib.abc` module contains all of the core abstract base classes used by :keyword:`import`. Some subclasses of the core abstract base classes are also provided to help in implementing the core ABCs. @@ -596,8 +596,8 @@ ABC hierarchy:: itself does not end in ``__init__``. -:mod:`importlib.machinery` -- Importers and path hooks ------------------------------------------------------- +:mod:`!importlib.machinery` -- Importers and path hooks +------------------------------------------------------- .. module:: importlib.machinery :synopsis: Importers and path hooks @@ -1112,8 +1112,8 @@ find and load modules. Path to the ``.fwork`` file for the extension module. -:mod:`importlib.util` -- Utility code for importers ---------------------------------------------------- +:mod:`!importlib.util` -- Utility code for importers +---------------------------------------------------- .. module:: importlib.util :synopsis: Utility code for importers diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 57353bfb9717d1..1455d907de8888 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -360,7 +360,7 @@ attributes (see :ref:`import-mod-attrs` for module attributes): Add ``f_generator`` attribute to frames. -.. versionchanged:: next +.. versionchanged:: 3.15 Add ``gi_state`` attribute to generators, ``cr_state`` attribute to coroutines, and ``ag_state`` attribute to async generators. diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 50a41cc29da0f6..57aad5ba9d1793 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -748,7 +748,7 @@ Command-line interface -------------- The :mod:`!json` module can be invoked as a script via ``python -m json`` -to validate and pretty-print JSON objects. The :mod:`json.tool` submodule +to validate and pretty-print JSON objects. The :mod:`!json.tool` submodule implements this interface. If the optional ``infile`` and ``outfile`` arguments are not diff --git a/Doc/library/mailbox.rst b/Doc/library/mailbox.rst index 62e289573c0c7e..ed135bf02cb968 100644 --- a/Doc/library/mailbox.rst +++ b/Doc/library/mailbox.rst @@ -1025,7 +1025,7 @@ Supported mailbox formats are Maildir, mbox, MH, Babyl, and MMDF. .. method:: remove_flag(flag) Unset the flag(s) specified by *flag* without changing other flags. To - remove more than one flag at a time, *flag* maybe a string of more than + remove more than one flag at a time, *flag* may be a string of more than one character. If "info" contains experimental information rather than flags, the current "info" is not modified. @@ -1190,7 +1190,7 @@ When a :class:`!MaildirMessage` instance is created based upon a .. method:: remove_flag(flag) Unset the flag(s) specified by *flag* without changing other flags. To - remove more than one flag at a time, *flag* maybe a string of more than + remove more than one flag at a time, *flag* may be a string of more than one character. When an :class:`!mboxMessage` instance is created based upon a @@ -1562,7 +1562,7 @@ When a :class:`!BabylMessage` instance is created based upon an .. method:: remove_flag(flag) Unset the flag(s) specified by *flag* without changing other flags. To - remove more than one flag at a time, *flag* maybe a string of more than + remove more than one flag at a time, *flag* may be a string of more than one character. When an :class:`!MMDFMessage` instance is created based upon a @@ -1641,7 +1641,7 @@ The following exception classes are defined in the :mod:`!mailbox` module: .. exception:: Error() - The based class for all other module-specific exceptions. + The base class for all other module-specific exceptions. .. exception:: NoSuchMailboxError() @@ -1661,7 +1661,7 @@ The following exception classes are defined in the :mod:`!mailbox` module: Raised when some mailbox-related condition beyond the control of the program causes it to be unable to proceed, such as when failing to acquire a lock that - another program already holds a lock, or when a uniquely generated file name + another program already holds, or when a uniquely generated file name already exists. diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index d3baf2d760f615..2b67d10d7bf1b7 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -279,7 +279,7 @@ processes: p.join() Queues are thread and process safe. - Any object put into a :mod:`~multiprocessing` queue will be serialized. + Any object put into a :mod:`!multiprocessing` queue will be serialized. **Pipes** @@ -1222,7 +1222,7 @@ Miscellaneous Set the path of the Python interpreter to use when starting a child process. (By default :data:`sys.executable` is used). Embedders will probably need to - do some thing like :: + do something like :: set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe')) @@ -1257,7 +1257,7 @@ Miscellaneous .. versionadded:: 3.4 - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *on_error* parameter. .. function:: set_start_method(method, force=False) @@ -1725,13 +1725,13 @@ inherited by child processes. attributes which allow one to use it to store and retrieve strings. -The :mod:`multiprocessing.sharedctypes` module -"""""""""""""""""""""""""""""""""""""""""""""" +The :mod:`!multiprocessing.sharedctypes` module +""""""""""""""""""""""""""""""""""""""""""""""" .. module:: multiprocessing.sharedctypes :synopsis: Allocate ctypes objects from shared memory. -The :mod:`multiprocessing.sharedctypes` module provides functions for allocating +The :mod:`!multiprocessing.sharedctypes` module provides functions for allocating :mod:`ctypes` objects from shared memory which can be inherited by child processes. @@ -2473,7 +2473,7 @@ with the :class:`Pool` class. duration of the Pool's work queue. A frequent pattern found in other systems (such as Apache, mod_wsgi, etc) to free resources held by workers is to allow a worker within a pool to complete only a set - amount of work before being exiting, being cleaned up and a new + amount of work before exiting, being cleaned up and a new process spawned to replace the old one. The *maxtasksperchild* argument to the :class:`Pool` exposes this ability to the end user. @@ -2658,7 +2658,7 @@ Usually message passing between processes is done using queues or by using :class:`~Connection` objects returned by :func:`~multiprocessing.Pipe`. -However, the :mod:`multiprocessing.connection` module allows some extra +However, the :mod:`!multiprocessing.connection` module allows some extra flexibility. It basically gives a high level message oriented API for dealing with sockets or Windows named pipes. It also has support for *digest authentication* using the :mod:`hmac` module, and for polling @@ -2965,18 +2965,18 @@ Below is an example session with logging turned on:: For a full table of logging levels, see the :mod:`logging` module. -The :mod:`multiprocessing.dummy` module -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The :mod:`!multiprocessing.dummy` module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. module:: multiprocessing.dummy :synopsis: Dumb wrapper around threading. -:mod:`multiprocessing.dummy` replicates the API of :mod:`!multiprocessing` but is +:mod:`!multiprocessing.dummy` replicates the API of :mod:`!multiprocessing` but is no more than a wrapper around the :mod:`threading` module. .. currentmodule:: multiprocessing.pool -In particular, the ``Pool`` function provided by :mod:`multiprocessing.dummy` +In particular, the ``Pool`` function provided by :mod:`!multiprocessing.dummy` returns an instance of :class:`ThreadPool`, which is a subclass of :class:`Pool` that supports all the same method calls but uses a pool of worker threads rather than worker processes. diff --git a/Doc/library/os.path.rst b/Doc/library/os.path.rst index 70ff6256821d7d..808187061733be 100644 --- a/Doc/library/os.path.rst +++ b/Doc/library/os.path.rst @@ -120,7 +120,7 @@ the :mod:`glob` module.) .. versionchanged:: 3.6 Accepts a :term:`path-like object`. - .. deprecated:: next + .. deprecated:: 3.15 Deprecated in favor of :func:`os.path.commonpath` for path prefixes. The :func:`os.path.commonprefix` function is being deprecated due to having a misleading name and module. The function is not safe to use for diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 13bbd9d61e947b..7418f3a8bacb0f 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -111,7 +111,7 @@ Python UTF-8 Mode .. versionchanged:: 3.15 Python UTF-8 mode is now enabled by default (:pep:`686`). - It may be disabled with by setting :envvar:`PYTHONUTF8=0 ` as + It may be disabled by setting :envvar:`PYTHONUTF8=0 ` as an environment variable or by using the :option:`-X utf8=0 <-X>` command line option. The Python UTF-8 Mode ignores the :term:`locale encoding` and forces the usage @@ -254,7 +254,7 @@ process and user. .. warning:: This function is not thread-safe. Calling it while the environment is - being modified in an other thread is an undefined behavior. Reading from + being modified in another thread is an undefined behavior. Reading from :data:`os.environ` or :data:`os.environb`, or calling :func:`os.getenv` while reloading, may return an empty result. @@ -4371,7 +4371,7 @@ Naturally, they are all only available on Linux. except it includes any time that the system is suspended. The file descriptor's behaviour can be modified by specifying a *flags* value. - Any of the following variables may used, combined using bitwise OR + Any of the following variables may be used, combined using bitwise OR (the ``|`` operator): - :const:`TFD_NONBLOCK` @@ -4403,7 +4403,7 @@ Naturally, they are all only available on Linux. *fd* must be a valid timer file descriptor. The timer's behaviour can be modified by specifying a *flags* value. - Any of the following variables may used, combined using bitwise OR + Any of the following variables may be used, combined using bitwise OR (the ``|`` operator): - :const:`TFD_TIMER_ABSTIME` @@ -4472,7 +4472,7 @@ Naturally, they are all only available on Linux. Return a two-item tuple of floats (``next_expiration``, ``interval``). - ``next_expiration`` denotes the relative time until next the timer next fires, + ``next_expiration`` denotes the relative time until the timer next fires, regardless of if the :const:`TFD_TIMER_ABSTIME` flag is set. ``interval`` denotes the timer's interval. diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst index 4814f5f86b2907..2b4aa1ee209997 100644 --- a/Doc/library/pathlib.rst +++ b/Doc/library/pathlib.rst @@ -1946,7 +1946,7 @@ Protocols :synopsis: pathlib types for static type checking -The :mod:`pathlib.types` module provides types for static type checking. +The :mod:`!pathlib.types` module provides types for static type checking. .. versionadded:: 3.14 diff --git a/Doc/library/pdb.rst b/Doc/library/pdb.rst index 8ab3e7ec9ef9d2..bfe017a5c8fe1c 100644 --- a/Doc/library/pdb.rst +++ b/Doc/library/pdb.rst @@ -1,7 +1,7 @@ .. _debugger: -:mod:`pdb` --- The Python Debugger -================================== +:mod:`!pdb` --- The Python Debugger +=================================== .. module:: pdb :synopsis: The Python debugger for interactive interpreters. @@ -12,7 +12,7 @@ -------------- -The module :mod:`pdb` defines an interactive source code debugger for Python +The module :mod:`!pdb` defines an interactive source code debugger for Python programs. It supports setting (conditional) breakpoints and single stepping at the source line level, inspection of stack frames, source code listing, and evaluation of arbitrary Python code in the context of any stack frame. It also @@ -82,7 +82,7 @@ Command-line interface .. program:: pdb -You can also invoke :mod:`pdb` from the command line to debug other scripts. For +You can also invoke :mod:`!pdb` from the command line to debug other scripts. For example:: python -m pdb [-c command] (-m module | -p pid | pyfile) [args ...] diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst index d3468cce39b6d2..02b79a9f3a7a47 100644 --- a/Doc/library/pickle.rst +++ b/Doc/library/pickle.rst @@ -519,7 +519,7 @@ The following types can be pickled: * classes accessible from the top level of a module; -* instances of such classes whose the result of calling :meth:`~object.__getstate__` +* instances of such classes for which the result of calling :meth:`~object.__getstate__` is picklable (see section :ref:`pickle-inst` for details). Attempts to pickle unpicklable objects will raise the :exc:`PicklingError` @@ -588,7 +588,7 @@ methods: .. method:: object.__getnewargs_ex__() - In protocols 2 and newer, classes that implements the + In protocols 2 and newer, classes that implement the :meth:`__getnewargs_ex__` method can dictate the values passed to the :meth:`__new__` method upon unpickling. The method must return a pair ``(args, kwargs)`` where *args* is a tuple of positional arguments diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst index 218aa88bc49d47..f7e85d1598727f 100644 --- a/Doc/library/profile.rst +++ b/Doc/library/profile.rst @@ -14,10 +14,10 @@ .. deprecated-removed:: 3.15 3.17 -The :mod:`profile` module is deprecated and will be removed in Python 3.17. +The :mod:`!profile` module is deprecated and will be removed in Python 3.17. Use :mod:`profiling.tracing` instead. -The :mod:`profile` module provides a pure Python implementation of a +The :mod:`!profile` module provides a pure Python implementation of a deterministic profiler. While useful for understanding profiler internals or extending profiler behavior through subclassing, its pure Python implementation introduces significant overhead compared to the C-based :mod:`profiling.tracing` @@ -32,7 +32,7 @@ For most profiling tasks, use: Migration ========= -Migrating from :mod:`profile` to :mod:`profiling.tracing` is straightforward. +Migrating from :mod:`!profile` to :mod:`profiling.tracing` is straightforward. The APIs are compatible:: # Old (deprecated) @@ -57,7 +57,7 @@ a straightforward migration path. :mod:`!profile` and :mod:`!profiling.tracing` module reference ============================================================== -Both the :mod:`profile` and :mod:`profiling.tracing` modules provide the +Both the :mod:`!profile` and :mod:`profiling.tracing` modules provide the following functions: .. function:: run(command, filename=None, sort=-1) @@ -114,7 +114,7 @@ following functions: print(s.getvalue()) The :class:`Profile` class can also be used as a context manager (supported - only in :mod:`profiling.tracing`, not in the deprecated :mod:`profile` + only in :mod:`profiling.tracing`, not in the deprecated :mod:`!profile` module; see :ref:`typecontextmanager`):: import profiling.tracing @@ -178,18 +178,18 @@ printed. Differences from :mod:`!profiling.tracing` ========================================== -The :mod:`profile` module differs from :mod:`profiling.tracing` in several +The :mod:`!profile` module differs from :mod:`profiling.tracing` in several ways: **Higher overhead.** The pure Python implementation is significantly slower than the C implementation, making it unsuitable for profiling long-running programs or performance-sensitive code. -**Calibration support.** The :mod:`profile` module supports calibration to +**Calibration support.** The :mod:`!profile` module supports calibration to compensate for profiling overhead. This is not needed in :mod:`profiling.tracing` because the C implementation has negligible overhead. -**Custom timers.** Both modules support custom timers, but :mod:`profile` +**Custom timers.** Both modules support custom timers, but :mod:`!profile` accepts timer functions that return tuples (like :func:`os.times`), while :mod:`profiling.tracing` requires a function returning a single number. @@ -254,9 +254,9 @@ this error. The error that accumulates in this fashion is typically less than the accuracy of the clock (less than one clock tick), but it *can* accumulate and become very significant. -The problem is more important with the deprecated :mod:`profile` module than +The problem is more important with the deprecated :mod:`!profile` module than with the lower-overhead :mod:`profiling.tracing`. For this reason, -:mod:`profile` provides a means of calibrating itself for a given platform so +:mod:`!profile` provides a means of calibrating itself for a given platform so that this error can be probabilistically (on the average) removed. After the profiler is calibrated, it will be more accurate (in a least square sense), but it will sometimes produce negative numbers (when call counts are exceptionally @@ -271,7 +271,7 @@ calibration. Calibration =========== -The profiler of the :mod:`profile` module subtracts a constant from each event +The profiler of the :mod:`!profile` module subtracts a constant from each event handling time to compensate for the overhead of calling the time function, and socking away the results. By default, the constant is 0. The following procedure can be used to obtain a better constant for a given platform (see diff --git a/Doc/library/profiling.rst b/Doc/library/profiling.rst index 9b58cae28ab781..f4ac47826b28ef 100644 --- a/Doc/library/profiling.rst +++ b/Doc/library/profiling.rst @@ -2,9 +2,9 @@ .. _profiling-module: -*************************************** -:mod:`profiling` --- Python profilers -*************************************** +************************************** +:mod:`!profiling` --- Python profilers +************************************** .. module:: profiling :synopsis: Python profiling tools for performance analysis. @@ -31,7 +31,7 @@ performance bottlenecks and guide optimization efforts. Python provides two fundamentally different approaches to collecting this information: statistical sampling and deterministic tracing. -The :mod:`profiling` package organizes Python's built-in profiling tools under +The :mod:`!profiling` package organizes Python's built-in profiling tools under a single namespace. It contains two submodules, each implementing a different profiling methodology: diff --git a/Doc/library/profiling.sampling.rst b/Doc/library/profiling.sampling.rst index 6c37a8d34cbd42..078062c08c6020 100644 --- a/Doc/library/profiling.sampling.rst +++ b/Doc/library/profiling.sampling.rst @@ -3,7 +3,7 @@ .. _profiling-sampling: *************************************************** -:mod:`profiling.sampling` --- Statistical profiler +:mod:`!profiling.sampling` --- Statistical profiler *************************************************** .. module:: profiling.sampling @@ -22,7 +22,7 @@ :align: center :width: 300px -The :mod:`profiling.sampling` module, named **Tachyon**, provides statistical +The :mod:`!profiling.sampling` module, named **Tachyon**, provides statistical profiling of Python programs through periodic stack sampling. Tachyon can run scripts directly or attach to any running Python process without requiring code changes or restarts. Because sampling occurs externally to the target diff --git a/Doc/library/profiling.tracing.rst b/Doc/library/profiling.tracing.rst index 6e6ba9173a1d2f..d45423cf0d8a72 100644 --- a/Doc/library/profiling.tracing.rst +++ b/Doc/library/profiling.tracing.rst @@ -1,7 +1,7 @@ .. _profiling-tracing: **************************************************** -:mod:`profiling.tracing` --- Deterministic profiler +:mod:`!profiling.tracing` --- Deterministic profiler **************************************************** .. module:: profiling.tracing @@ -17,7 +17,7 @@ -------------- -The :mod:`profiling.tracing` module provides deterministic profiling of Python +The :mod:`!profiling.tracing` module provides deterministic profiling of Python programs. It monitors every function call, function return, and exception event, recording precise timing for each. This approach provides exact call counts and complete visibility into program execution, making it ideal for development and @@ -79,7 +79,7 @@ Command-line interface .. program:: profiling.tracing -The :mod:`profiling.tracing` module can be invoked as a script to profile +The :mod:`!profiling.tracing` module can be invoked as a script to profile another script or module: .. code-block:: shell-session @@ -311,7 +311,7 @@ this latency, which can make them appear slower than they actually are. This error is typically less than one clock tick per call but can become significant for functions called many times. -The :mod:`profiling.tracing` module (and its ``cProfile`` alias) is +The :mod:`!profiling.tracing` module (and its ``cProfile`` alias) is implemented as a C extension with low overhead, so these timing issues are less pronounced than with the deprecated pure Python :mod:`profile` module. diff --git a/Doc/library/pstats.rst b/Doc/library/pstats.rst index ce1cc5c9535ca6..585f17bdb99a70 100644 --- a/Doc/library/pstats.rst +++ b/Doc/library/pstats.rst @@ -1,8 +1,8 @@ .. _pstats-module: -******************************************** -:mod:`pstats` --- Statistics for profilers -******************************************** +******************************************* +:mod:`!pstats` --- Statistics for profilers +******************************************* .. module:: pstats :synopsis: Statistics object for analyzing profiler output. @@ -11,7 +11,7 @@ -------------- -The :mod:`pstats` module provides tools for reading, manipulating, and +The :mod:`!pstats` module provides tools for reading, manipulating, and displaying profiling statistics generated by Python's profilers. It reads output from both :mod:`profiling.tracing` (deterministic profiler) and :mod:`profiling.sampling` (statistical profiler). @@ -341,7 +341,7 @@ The :class:`!Stats` class Command-line interface ====================== -The :mod:`pstats` module can be invoked as a script to interactively browse +The :mod:`!pstats` module can be invoked as a script to interactively browse profile data:: python -m pstats profile_output.prof diff --git a/Doc/library/pyexpat.rst b/Doc/library/pyexpat.rst index 0910c2d50791e8..ff5265835da3f8 100644 --- a/Doc/library/pyexpat.rst +++ b/Doc/library/pyexpat.rst @@ -485,7 +485,7 @@ otherwise stated. ...``). The *doctypeName* is provided exactly as presented. The *systemId* and *publicId* parameters give the system and public identifiers if specified, or ``None`` if omitted. *has_internal_subset* will be true if the document - contains and internal document declaration subset. This requires Expat version + contains an internal document declaration subset. This requires Expat version 1.2 or newer. @@ -759,7 +759,7 @@ values: the type, the quantifier, the name, and a tuple of children. Children are simply additional content model descriptions. The values of the first two fields are constants defined in the -:mod:`xml.parsers.expat.model` module. These constants can be collected in two +:mod:`!xml.parsers.expat.model` module. These constants can be collected in two groups: the model type group and the quantifier group. The constants in the model type group are: @@ -833,7 +833,7 @@ Expat error constants .. module:: xml.parsers.expat.errors -The following constants are provided in the :mod:`xml.parsers.expat.errors` +The following constants are provided in the :mod:`!xml.parsers.expat.errors` module. These constants are useful in interpreting some of the attributes of the :exc:`ExpatError` exception objects raised when an error has occurred. Since for backwards compatibility reasons, the constants' value is the error diff --git a/Doc/library/resource.rst b/Doc/library/resource.rst index c58dc4243ecb19..b176a28fdfe35b 100644 --- a/Doc/library/resource.rst +++ b/Doc/library/resource.rst @@ -356,9 +356,9 @@ These functions are used to retrieve resource usage information: print(getrusage(RUSAGE_SELF)) The fields of the return value each describe how a particular system resource - has been used, e.g. amount of time spent running is user mode or number of times + has been used, e.g. amount of time spent running in user mode or number of times the process was swapped out of main memory. Some values are dependent on the - clock tick internal, e.g. the amount of memory the process is using. + clock tick interval, e.g. the amount of memory the process is using. For backward compatibility, the return value is also accessible as a tuple of 16 elements. diff --git a/Doc/library/secrets.rst b/Doc/library/secrets.rst index 997d1f32cccd75..e266849918a80b 100644 --- a/Doc/library/secrets.rst +++ b/Doc/library/secrets.rst @@ -120,7 +120,7 @@ argument to the various ``token_*`` functions. That argument is taken as the number of bytes of randomness to use. Otherwise, if no argument is provided, or if the argument is ``None``, -the ``token_*`` functions uses :const:`DEFAULT_ENTROPY` instead. +the ``token_*`` functions use :const:`DEFAULT_ENTROPY` instead. .. data:: DEFAULT_ENTROPY diff --git a/Doc/library/select.rst b/Doc/library/select.rst index 9effd9752c68a7..f6d8ce3c30ff1d 100644 --- a/Doc/library/select.rst +++ b/Doc/library/select.rst @@ -174,7 +174,7 @@ The module defines the following: The minimum number of bytes which can be written without blocking to a pipe when the pipe has been reported as ready for writing by :func:`~select.select`, :func:`!poll` or another interface in this module. This doesn't apply - to other kind of file-like objects such as sockets. + to other kinds of file-like objects such as sockets. This value is guaranteed by POSIX to be at least 512. @@ -226,7 +226,7 @@ object. implement :meth:`!fileno`, so they can also be used as the argument. *eventmask* is an optional bitmask describing the type of events you want to - check for. The constants are the same that with :c:func:`!poll` + check for. The constants are the same as with :c:func:`!poll` object. The default value is a combination of the constants :const:`POLLIN`, :const:`POLLPRI`, and :const:`POLLOUT`. @@ -241,7 +241,7 @@ object. .. method:: devpoll.modify(fd[, eventmask]) This method does an :meth:`unregister` followed by a - :meth:`register`. It is (a bit) more efficient that doing the same + :meth:`register`. It is (a bit) more efficient than doing the same explicitly. @@ -580,9 +580,9 @@ https://man.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2 +---------------------------+---------------------------------------------+ | :const:`KQ_EV_DELETE` | Removes an event from the queue | +---------------------------+---------------------------------------------+ - | :const:`KQ_EV_ENABLE` | Permitscontrol() to returns the event | + | :const:`KQ_EV_ENABLE` | Permits control() to return the event | +---------------------------+---------------------------------------------+ - | :const:`KQ_EV_DISABLE` | Disablesevent | + | :const:`KQ_EV_DISABLE` | Disables event | +---------------------------+---------------------------------------------+ | :const:`KQ_EV_ONESHOT` | Removes event after first occurrence | +---------------------------+---------------------------------------------+ diff --git a/Doc/library/selectors.rst b/Doc/library/selectors.rst index ee556f1f3cecae..2d523a9d2ea440 100644 --- a/Doc/library/selectors.rst +++ b/Doc/library/selectors.rst @@ -54,7 +54,7 @@ Classes hierarchy:: In the following, *events* is a bitwise mask indicating which I/O events should -be waited for on a given file object. It can be a combination of the modules +be waited for on a given file object. It can be a combination of the module's constants below: +-----------------------+-----------------------------------------------+ diff --git a/Doc/library/shelve.rst b/Doc/library/shelve.rst index a8d22f3b8a033d..bd3d56f6af595a 100644 --- a/Doc/library/shelve.rst +++ b/Doc/library/shelve.rst @@ -51,7 +51,7 @@ lots of shared sub-objects. The keys are ordinary strings. :term:`bytes-like object`; the *protocol* value may be ignored by the serializer. - The *deserializer* argument must be callable which takes a serialized object + The *deserializer* argument must be a callable which takes a serialized object given as a :class:`bytes` object and returns the corresponding object. A :exc:`ShelveError` is raised if *serializer* is given but *deserializer* @@ -85,7 +85,7 @@ lots of shared sub-objects. The keys are ordinary strings. to load a shelf from an untrusted source. Like with pickle, loading a shelf can execute arbitrary code. -Shelf objects support most of methods and operations supported by dictionaries +Shelf objects support most of the methods and operations supported by dictionaries (except copying, constructors and operators ``|`` and ``|=``). This eases the transition from dictionary based scripts to those requiring persistent storage. diff --git a/Doc/library/shlex.rst b/Doc/library/shlex.rst index 00f4920a3268a8..0653bf2f4189c2 100644 --- a/Doc/library/shlex.rst +++ b/Doc/library/shlex.rst @@ -343,7 +343,7 @@ variables which either control lexical analysis or can be used for debugging: Parsing Rules ------------- -When operating in non-POSIX mode, :class:`~shlex.shlex` will try to obey to the +When operating in non-POSIX mode, :class:`~shlex.shlex` will try to obey the following rules. * Quote characters are not recognized within words (``Do"Not"Separate`` is @@ -366,7 +366,7 @@ following rules. * It's not possible to parse empty strings, even if quoted. -When operating in POSIX mode, :class:`~shlex.shlex` will try to obey to the +When operating in POSIX mode, :class:`~shlex.shlex` will try to obey the following parsing rules. * Quotes are stripped out, and do not separate words (``"Do"Not"Separate"`` is @@ -382,7 +382,7 @@ following parsing rules. * Enclosing characters in quotes which are part of :attr:`~shlex.escapedquotes` (e.g. ``'"'``) preserves the literal value of all characters within the quotes, with the exception of the characters - mentioned in :attr:`~shlex.escape`. The escape characters retain its + mentioned in :attr:`~shlex.escape`. The escape characters retain their special meaning only when followed by the quote in use, or the escape character itself. Otherwise the escape character will be considered a normal character. diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 647e9bbd1d46a5..33f56121e84514 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -540,12 +540,12 @@ On Solaris :func:`os.sendfile` is used. On Windows :func:`shutil.copyfile` uses a bigger default buffer size (1 MiB instead of 64 KiB) and a :func:`memoryview`-based variant of -:func:`shutil.copyfileobj` is used, which is still reads and writes in a loop. +:func:`shutil.copyfileobj` is used, which still reads and writes in a loop. :func:`shutil.copy2` uses the native ``CopyFile2`` call on Windows, which is the most efficient method, supports copy-on-write, and preserves metadata. If the fast-copy operation fails and no data was written in the destination -file then shutil will silently fallback on using less efficient +file then shutil will silently fall back to less efficient :func:`copyfileobj` function internally. .. versionchanged:: 3.8 diff --git a/Doc/library/signal.rst b/Doc/library/signal.rst index 485eb6058c7e20..d85d7138911016 100644 --- a/Doc/library/signal.rst +++ b/Doc/library/signal.rst @@ -36,7 +36,7 @@ Execution of Python signal handlers A Python signal handler does not get executed inside the low-level (C) signal handler. Instead, the low-level signal handler sets a flag which tells the :term:`virtual machine` to execute the corresponding Python signal handler -at a later point(for example at the next :term:`bytecode` instruction). +at a later point (for example, at the next :term:`bytecode` instruction). This has consequences: * It makes little sense to catch synchronous errors like :const:`SIGFPE` or @@ -92,13 +92,13 @@ The signal module defines three enums: .. class:: Handlers - :class:`enum.IntEnum` collection the constants :const:`SIG_DFL` and :const:`SIG_IGN`. + :class:`enum.IntEnum` collection of the constants :const:`SIG_DFL` and :const:`SIG_IGN`. .. versionadded:: 3.5 .. class:: Sigmasks - :class:`enum.IntEnum` collection the constants :const:`SIG_BLOCK`, :const:`SIG_UNBLOCK` and :const:`SIG_SETMASK`. + :class:`enum.IntEnum` collection of the constants :const:`SIG_BLOCK`, :const:`SIG_UNBLOCK` and :const:`SIG_SETMASK`. .. availability:: Unix. diff --git a/Doc/library/site.rst b/Doc/library/site.rst index 09a98b4e3b22af..4686c9fc92ced2 100644 --- a/Doc/library/site.rst +++ b/Doc/library/site.rst @@ -130,38 +130,38 @@ directory precedes the :file:`foo` directory because :file:`bar.pth` comes alphabetically before :file:`foo.pth`; and :file:`spam` is omitted because it is not mentioned in either path configuration file. -:mod:`sitecustomize` --------------------- +:mod:`!sitecustomize` +--------------------- .. module:: sitecustomize After these path manipulations, an attempt is made to import a module named -:mod:`sitecustomize`, which can perform arbitrary site-specific customizations. +:mod:`!sitecustomize`, which can perform arbitrary site-specific customizations. It is typically created by a system administrator in the site-packages directory. If this import fails with an :exc:`ImportError` or its subclass exception, and the exception's :attr:`~ImportError.name` -attribute equals to ``'sitecustomize'``, +attribute equals ``'sitecustomize'``, it is silently ignored. If Python is started without output streams available, as with :file:`pythonw.exe` on Windows (which is used by default to start IDLE), -attempted output from :mod:`sitecustomize` is ignored. Any other exception +attempted output from :mod:`!sitecustomize` is ignored. Any other exception causes a silent and perhaps mysterious failure of the process. -:mod:`usercustomize` --------------------- +:mod:`!usercustomize` +--------------------- .. module:: usercustomize -After this, an attempt is made to import a module named :mod:`usercustomize`, +After this, an attempt is made to import a module named :mod:`!usercustomize`, which can perform arbitrary user-specific customizations, if :data:`~site.ENABLE_USER_SITE` is true. This file is intended to be created in the user site-packages directory (see below), which is part of ``sys.path`` unless disabled by :option:`-s`. If this import fails with an :exc:`ImportError` or its subclass exception, and the exception's :attr:`~ImportError.name` -attribute equals to ``'usercustomize'``, it is silently ignored. +attribute equals ``'usercustomize'``, it is silently ignored. Note that for some non-Unix systems, ``sys.prefix`` and ``sys.exec_prefix`` are empty, and the path manipulations are skipped; however the import of -:mod:`sitecustomize` and :mod:`usercustomize` is still attempted. +:mod:`sitecustomize` and :mod:`!usercustomize` is still attempted. .. currentmodule:: site @@ -173,7 +173,7 @@ Readline configuration On systems that support :mod:`readline`, this module will also import and configure the :mod:`rlcompleter` module, if Python is started in :ref:`interactive mode ` and without the :option:`-S` option. -The default behavior is enable tab-completion and to use +The default behavior is to enable tab completion and to use :file:`~/.python_history` as the history save file. To disable it, delete (or override) the :data:`sys.__interactivehook__` attribute in your :mod:`sitecustomize` or :mod:`usercustomize` module or your diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index ac962f5beeb149..24ce0ee56d92a6 100644 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -118,10 +118,10 @@ created. Socket addresses are represented as follows: ``'can0'``. The network interface name ``''`` can be used to receive packets from all network interfaces of this family. - - :const:`CAN_ISOTP` protocol require a tuple ``(interface, rx_addr, tx_addr)`` + - :const:`CAN_ISOTP` protocol requires a tuple ``(interface, rx_addr, tx_addr)`` where both additional parameters are unsigned long integer that represent a CAN identifier (standard or extended). - - :const:`CAN_J1939` protocol require a tuple ``(interface, name, pgn, addr)`` + - :const:`CAN_J1939` protocol requires a tuple ``(interface, name, pgn, addr)`` where additional parameters are 64-bit unsigned integer representing the ECU name, a 32-bit unsigned integer representing the Parameter Group Number (PGN), and an 8-bit integer representing the address. @@ -1037,7 +1037,7 @@ The :mod:`!socket` module also offers various network-related services: .. function:: close(fd) Close a socket file descriptor. This is like :func:`os.close`, but for - sockets. On some platforms (most noticeable Windows) :func:`os.close` + sockets. On some platforms (most notably Windows) :func:`os.close` does not work for socket file descriptors. .. versionadded:: 3.7 @@ -1602,7 +1602,7 @@ to sockets. address family --- see above.) If the connection is interrupted by a signal, the method waits until the - connection completes, or raise a :exc:`TimeoutError` on timeout, if the + connection completes, or raises a :exc:`TimeoutError` on timeout, if the signal handler doesn't raise an exception and the socket is blocking or has a timeout. For non-blocking sockets, the method raises an :exc:`InterruptedError` exception if the connection is interrupted by a @@ -2109,11 +2109,11 @@ to sockets. Set the value of the given socket option (see the Unix manual page :manpage:`setsockopt(2)`). The needed symbolic constants are defined in this module (:ref:`!SO_\* etc. `). The value can be an integer, - ``None`` or a :term:`bytes-like object` representing a buffer. In the later + ``None`` or a :term:`bytes-like object` representing a buffer. In the latter case it is up to the caller to ensure that the bytestring contains the proper bits (see the optional built-in module :mod:`struct` for a way to encode C structures as bytestrings). When *value* is set to ``None``, - *optlen* argument is required. It's equivalent to call :c:func:`setsockopt` C + *optlen* argument is required. It's equivalent to calling :c:func:`setsockopt` C function with ``optval=NULL`` and ``optlen=optlen``. .. versionchanged:: 3.5 diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 3b1a9c2f6eefe9..02663e2054d5f1 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -291,7 +291,7 @@ Module functions Set it to any combination (using ``|``, bitwise or) of :const:`PARSE_DECLTYPES` and :const:`PARSE_COLNAMES` to enable this. - Column names takes precedence over declared types if both flags are set. + Column names take precedence over declared types if both flags are set. By default (``0``), type detection is disabled. :param isolation_level: diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index c8dc834fe84446..0e5f5dc39e7277 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -1441,108 +1441,111 @@ application). list appear empty for the duration, and raises :exc:`ValueError` if it can detect that the list has been mutated during a sort. -.. admonition:: Thread safety +.. _thread-safety-list: - Reading a single element from a :class:`list` is - :term:`atomic `: +.. rubric:: Thread safety for list objects - .. code-block:: - :class: green +Reading a single element from a :class:`list` is +:term:`atomic `: - lst[i] # list.__getitem__ +.. code-block:: + :class: green - The following methods traverse the list and use :term:`atomic ` - reads of each item to perform their function. That means that they may - return results affected by concurrent modifications: + lst[i] # list.__getitem__ - .. code-block:: - :class: maybe +The following methods traverse the list and use :term:`atomic ` +reads of each item to perform their function. That means that they may +return results affected by concurrent modifications: - item in lst - lst.index(item) - lst.count(item) +.. code-block:: + :class: maybe - All of the above methods/operations are also lock-free. They do not block - concurrent modifications. Other operations that hold a lock will not block - these from observing intermediate states. + item in lst + lst.index(item) + lst.count(item) - All other operations from here on block using the per-object lock. +All of the above operations avoid acquiring :term:`per-object locks +`. They do not block concurrent modifications. Other +operations that hold a lock will not block these from observing intermediate +states. - Writing a single item via ``lst[i] = x`` is safe to call from multiple - threads and will not corrupt the list. +All other operations from here on block using the :term:`per-object lock`. - The following operations return new objects and appear - :term:`atomic ` to other threads: +Writing a single item via ``lst[i] = x`` is safe to call from multiple +threads and will not corrupt the list. - .. code-block:: - :class: good +The following operations return new objects and appear +:term:`atomic ` to other threads: - lst1 + lst2 # concatenates two lists into a new list - x * lst # repeats lst x times into a new list - lst.copy() # returns a shallow copy of the list +.. code-block:: + :class: good - Methods that only operate on a single elements with no shifting required are - :term:`atomic `: + lst1 + lst2 # concatenates two lists into a new list + x * lst # repeats lst x times into a new list + lst.copy() # returns a shallow copy of the list - .. code-block:: - :class: good +The following methods that only operate on a single element with no shifting +required are :term:`atomic `: - lst.append(x) # append to the end of the list, no shifting required - lst.pop() # pop element from the end of the list, no shifting required +.. code-block:: + :class: good - The :meth:`~list.clear` method is also :term:`atomic `. - Other threads cannot observe elements being removed. + lst.append(x) # append to the end of the list, no shifting required + lst.pop() # pop element from the end of the list, no shifting required - The :meth:`~list.sort` method is not :term:`atomic `. - Other threads cannot observe intermediate states during sorting, but the - list appears empty for the duration of the sort. +The :meth:`~list.clear` method is also :term:`atomic `. +Other threads cannot observe elements being removed. - The following operations may allow lock-free operations to observe - intermediate states since they modify multiple elements in place: +The :meth:`~list.sort` method is not :term:`atomic `. +Other threads cannot observe intermediate states during sorting, but the +list appears empty for the duration of the sort. - .. code-block:: - :class: maybe +The following operations may allow :term:`lock-free` operations to observe +intermediate states since they modify multiple elements in place: - lst.insert(idx, item) # shifts elements - lst.pop(idx) # idx not at the end of the list, shifts elements - lst *= x # copies elements in place +.. code-block:: + :class: maybe - The :meth:`~list.remove` method may allow concurrent modifications since - element comparison may execute arbitrary Python code (via - :meth:`~object.__eq__`). + lst.insert(idx, item) # shifts elements + lst.pop(idx) # idx not at the end of the list, shifts elements + lst *= x # copies elements in place - :meth:`~list.extend` is safe to call from multiple threads. However, its - guarantees depend on the iterable passed to it. If it is a :class:`list`, a - :class:`tuple`, a :class:`set`, a :class:`frozenset`, a :class:`dict` or a - :ref:`dictionary view object ` (but not their subclasses), the - ``extend`` operation is safe from concurrent modifications to the iterable. - Otherwise, an iterator is created which can be concurrently modified by - another thread. The same applies to inplace concatenation of a list with - other iterables when using ``lst += iterable``. +The :meth:`~list.remove` method may allow concurrent modifications since +element comparison may execute arbitrary Python code (via +:meth:`~object.__eq__`). - Similarly, assigning to a list slice with ``lst[i:j] = iterable`` is safe - to call from multiple threads, but ``iterable`` is only locked when it is - also a :class:`list` (but not its subclasses). +:meth:`~list.extend` is safe to call from multiple threads. However, its +guarantees depend on the iterable passed to it. If it is a :class:`list`, a +:class:`tuple`, a :class:`set`, a :class:`frozenset`, a :class:`dict` or a +:ref:`dictionary view object ` (but not their subclasses), the +``extend`` operation is safe from concurrent modifications to the iterable. +Otherwise, an iterator is created which can be concurrently modified by +another thread. The same applies to inplace concatenation of a list with +other iterables when using ``lst += iterable``. - Operations that involve multiple accesses, as well as iteration, are never - atomic. For example: +Similarly, assigning to a list slice with ``lst[i:j] = iterable`` is safe +to call from multiple threads, but ``iterable`` is only locked when it is +also a :class:`list` (but not its subclasses). - .. code-block:: - :class: bad +Operations that involve multiple accesses, as well as iteration, are never +atomic. For example: - # NOT atomic: read-modify-write - lst[i] = lst[i] + 1 +.. code-block:: + :class: bad - # NOT atomic: check-then-act - if lst: - item = lst.pop() + # NOT atomic: read-modify-write + lst[i] = lst[i] + 1 - # NOT thread-safe: iteration while modifying - for item in lst: - process(item) # another thread may modify lst + # NOT atomic: check-then-act + if lst: + item = lst.pop() - Consider external synchronization when sharing :class:`list` instances - across threads. See :ref:`freethreading-python-howto` for more information. + # NOT thread-safe: iteration while modifying + for item in lst: + process(item) # another thread may modify lst + +Consider external synchronization when sharing :class:`list` instances +across threads. See :ref:`freethreading-python-howto` for more information. .. _typesseq-tuple: @@ -5590,6 +5593,146 @@ can be used interchangeably to index the same dictionary entry. of a :class:`dict`. +.. _thread-safety-dict: + +.. rubric:: Thread safety for dict objects + +Creating a dictionary with the :class:`dict` constructor is atomic when the +argument to it is a :class:`dict` or a :class:`tuple`. When using the +:meth:`dict.fromkeys` method, dictionary creation is atomic when the +argument is a :class:`dict`, :class:`tuple`, :class:`set` or +:class:`frozenset`. + +The following operations and functions are :term:`lock-free` and +:term:`atomic `. + +.. code-block:: + :class: good + + d[key] # dict.__getitem__ + d.get(key) # dict.get + key in d # dict.__contains__ + len(d) # dict.__len__ + +All other operations from here on hold the :term:`per-object lock`. + +Writing or removing a single item is safe to call from multiple threads +and will not corrupt the dictionary: + +.. code-block:: + :class: good + + d[key] = value # write + del d[key] # delete + d.pop(key) # remove and return + d.popitem() # remove and return last item + d.setdefault(key, v) # insert if missing + +These operations may compare keys using :meth:`~object.__eq__`, which can +execute arbitrary Python code. During such comparisons, the dictionary may +be modified by another thread. For built-in types like :class:`str`, +:class:`int`, and :class:`float`, that implement :meth:`~object.__eq__` in C, +the underlying lock is not released during comparisons and this is not a +concern. + +The following operations return new objects and hold the :term:`per-object lock` +for the duration of the operation: + +.. code-block:: + :class: good + + d.copy() # returns a shallow copy of the dictionary + d | other # merges two dicts into a new dict + d.keys() # returns a new dict_keys view object + d.values() # returns a new dict_values view object + d.items() # returns a new dict_items view object + +The :meth:`~dict.clear` method holds the lock for its duration. Other +threads cannot observe elements being removed. + +The following operations lock both dictionaries. For :meth:`~dict.update` +and ``|=``, this applies only when the other operand is a :class:`dict` +that uses the standard dict iterator (but not subclasses that override +iteration). For equality comparison, this applies to :class:`dict` and +its subclasses: + +.. code-block:: + :class: good + + d.update(other_dict) # both locked when other_dict is a dict + d |= other_dict # both locked when other_dict is a dict + d == other_dict # both locked for dict and subclasses + +All comparison operations also compare values using :meth:`~object.__eq__`, +so for non-built-in types the lock may be released during comparison. + +:meth:`~dict.fromkeys` locks both the new dictionary and the iterable +when the iterable is exactly a :class:`dict`, :class:`set`, or +:class:`frozenset` (not subclasses): + +.. code-block:: + :class: good + + dict.fromkeys(a_dict) # locks both + dict.fromkeys(a_set) # locks both + dict.fromkeys(a_frozenset) # locks both + +When updating from a non-dict iterable, only the target dictionary is +locked. The iterable may be concurrently modified by another thread: + +.. code-block:: + :class: maybe + + d.update(iterable) # iterable is not a dict: only d locked + d |= iterable # iterable is not a dict: only d locked + dict.fromkeys(iterable) # iterable is not a dict/set/frozenset: only result locked + +Operations that involve multiple accesses, as well as iteration, are never +atomic: + +.. code-block:: + :class: bad + + # NOT atomic: read-modify-write + d[key] = d[key] + 1 + + # NOT atomic: check-then-act (TOCTOU) + if key in d: + del d[key] + + # NOT thread-safe: iteration while modifying + for key, value in d.items(): + process(key) # another thread may modify d + +To avoid time-of-check to time-of-use (TOCTOU) issues, use atomic +operations or handle exceptions: + +.. code-block:: + :class: good + + # Use pop() with default instead of check-then-delete + d.pop(key, None) + + # Or handle the exception + try: + del d[key] + except KeyError: + pass + +To safely iterate over a dictionary that may be modified by another +thread, iterate over a copy: + +.. code-block:: + :class: good + + # Make a copy to iterate safely + for key, value in d.copy().items(): + process(key) + +Consider external synchronization when sharing :class:`dict` instances +across threads. See :ref:`freethreading-python-howto` for more information. + + .. _dict-views: Dictionary view objects diff --git a/Doc/library/symtable.rst b/Doc/library/symtable.rst index 63549f440a5f13..264857f7b76aad 100644 --- a/Doc/library/symtable.rst +++ b/Doc/library/symtable.rst @@ -184,7 +184,7 @@ Examining Symbol Tables Return a tuple containing names of :term:`cell variables ` in this table. - .. versionadded:: next + .. versionadded:: 3.15 .. class:: Class @@ -301,7 +301,7 @@ Examining Symbol Tables Return ``True`` if the symbol is referenced but not assigned in a nested block. - .. versionadded:: next + .. versionadded:: 3.15 .. method:: is_free_class() diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index 5ddf88692ece35..76b205691bfeb4 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -560,7 +560,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only in the range 0--127, and produce undefined results otherwise. Some systems have a convention for assigning specific meanings to specific exit codes, but these are generally underdeveloped; Unix programs generally use 2 for command - line syntax errors and 1 for all other kind of errors. If another type of + line syntax errors and 1 for all other kinds of errors. If another type of object is passed, ``None`` is equivalent to passing zero, and any other object is printed to :data:`stderr` and results in an exit code of 1. In particular, ``sys.exit("some error message")`` is a quick way to exit a diff --git a/Doc/library/test.rst b/Doc/library/test.rst index a179ea6df057f1..b5a3005f854410 100644 --- a/Doc/library/test.rst +++ b/Doc/library/test.rst @@ -164,7 +164,7 @@ Running tests using the command-line interface The :mod:`!test` package can be run as a script to drive Python's regression test suite, thanks to the :option:`-m` option: :program:`python -m test`. Under -the hood, it uses :mod:`test.regrtest`; the call :program:`python -m +the hood, it uses :mod:`!test.regrtest`; the call :program:`python -m test.regrtest` used in previous Python versions still works. Running the script by itself automatically starts running all regression tests in the :mod:`!test` package. It does this by finding all modules in the package whose @@ -197,19 +197,19 @@ regression tests. :ref:`controlled using environment variables `. -:mod:`test.support` --- Utilities for the Python test suite -=========================================================== +:mod:`!test.support` --- Utilities for the Python test suite +============================================================ .. module:: test.support :synopsis: Support for Python's regression test suite. -The :mod:`test.support` module provides support for Python's regression +The :mod:`!test.support` module provides support for Python's regression test suite. .. note:: - :mod:`test.support` is not a public module. It is documented here to help + :mod:`!test.support` is not a public module. It is documented here to help Python developers write tests. The API of this module is subject to change without backwards compatibility concerns between releases. @@ -230,7 +230,7 @@ This module defines the following exceptions: function. -The :mod:`test.support` module defines the following constants: +The :mod:`!test.support` module defines the following constants: .. data:: verbose @@ -363,7 +363,7 @@ The :mod:`test.support` module defines the following constants: .. data:: TEST_SUPPORT_DIR - Set to the top level directory that contains :mod:`test.support`. + Set to the top level directory that contains :mod:`!test.support`. .. data:: TEST_HOME_DIR @@ -438,7 +438,7 @@ The :mod:`test.support` module defines the following constants: Used to test mixed type comparison. -The :mod:`test.support` module defines the following functions: +The :mod:`!test.support` module defines the following functions: .. function:: busy_retry(timeout, err_msg=None, /, *, error=True) @@ -1043,7 +1043,7 @@ The :mod:`test.support` module defines the following functions: .. versionadded:: 3.11 -The :mod:`test.support` module defines the following classes: +The :mod:`!test.support` module defines the following classes: .. class:: SuppressCrashReport() @@ -1089,14 +1089,14 @@ The :mod:`test.support` module defines the following classes: Try to match a single stored value (*dv*) with a supplied value (*v*). -:mod:`test.support.socket_helper` --- Utilities for socket tests -================================================================ +:mod:`!test.support.socket_helper` --- Utilities for socket tests +================================================================= .. module:: test.support.socket_helper :synopsis: Support for socket tests. -The :mod:`test.support.socket_helper` module provides support for socket tests. +The :mod:`!test.support.socket_helper` module provides support for socket tests. .. versionadded:: 3.9 @@ -1167,14 +1167,14 @@ The :mod:`test.support.socket_helper` module provides support for socket tests. exceptions. -:mod:`test.support.script_helper` --- Utilities for the Python execution tests -============================================================================== +:mod:`!test.support.script_helper` --- Utilities for the Python execution tests +=============================================================================== .. module:: test.support.script_helper :synopsis: Support for Python's script execution tests. -The :mod:`test.support.script_helper` module provides support for Python's +The :mod:`!test.support.script_helper` module provides support for Python's script execution tests. .. function:: interpreter_requires_environment() @@ -1278,13 +1278,13 @@ script execution tests. path and the archive name for the zip file. -:mod:`test.support.bytecode_helper` --- Support tools for testing correct bytecode generation -============================================================================================= +:mod:`!test.support.bytecode_helper` --- Support tools for testing correct bytecode generation +============================================================================================== .. module:: test.support.bytecode_helper :synopsis: Support tools for testing correct bytecode generation. -The :mod:`test.support.bytecode_helper` module provides support for testing +The :mod:`!test.support.bytecode_helper` module provides support for testing and inspecting bytecode generation. .. versionadded:: 3.9 @@ -1310,13 +1310,13 @@ The module defines the following class: Throws :exc:`AssertionError` if *opname* is found. -:mod:`test.support.threading_helper` --- Utilities for threading tests -====================================================================== +:mod:`!test.support.threading_helper` --- Utilities for threading tests +======================================================================= .. module:: test.support.threading_helper :synopsis: Support for threading tests. -The :mod:`test.support.threading_helper` module provides support for threading tests. +The :mod:`!test.support.threading_helper` module provides support for threading tests. .. versionadded:: 3.10 @@ -1397,13 +1397,13 @@ The :mod:`test.support.threading_helper` module provides support for threading t finished. -:mod:`test.support.os_helper` --- Utilities for os tests -======================================================================== +:mod:`!test.support.os_helper` --- Utilities for os tests +========================================================= .. module:: test.support.os_helper :synopsis: Support for os tests. -The :mod:`test.support.os_helper` module provides support for os tests. +The :mod:`!test.support.os_helper` module provides support for os tests. .. versionadded:: 3.10 @@ -1592,13 +1592,13 @@ The :mod:`test.support.os_helper` module provides support for os tests. wrapped with a wait loop that checks for the existence of the file. -:mod:`test.support.import_helper` --- Utilities for import tests -================================================================ +:mod:`!test.support.import_helper` --- Utilities for import tests +================================================================= .. module:: test.support.import_helper :synopsis: Support for import tests. -The :mod:`test.support.import_helper` module provides support for import tests. +The :mod:`!test.support.import_helper` module provides support for import tests. .. versionadded:: 3.10 @@ -1706,13 +1706,13 @@ The :mod:`test.support.import_helper` module provides support for import tests. will be reverted at the end of the block. -:mod:`test.support.warnings_helper` --- Utilities for warnings tests -==================================================================== +:mod:`!test.support.warnings_helper` --- Utilities for warnings tests +===================================================================== .. module:: test.support.warnings_helper :synopsis: Support for warnings tests. -The :mod:`test.support.warnings_helper` module provides support for warnings tests. +The :mod:`!test.support.warnings_helper` module provides support for warnings tests. .. versionadded:: 3.10 diff --git a/Doc/library/tomllib.rst b/Doc/library/tomllib.rst index d3767798055da4..dc6e0cc178bf66 100644 --- a/Doc/library/tomllib.rst +++ b/Doc/library/tomllib.rst @@ -18,7 +18,7 @@ support writing TOML. .. versionadded:: 3.11 The module was added with support for TOML 1.0.0. -.. versionchanged:: next +.. versionchanged:: 3.15 Added TOML 1.1.0 support. See the :ref:`What's New ` for details. diff --git a/Doc/library/trace.rst b/Doc/library/trace.rst index e0ae55ecc45acc..57b8fa29eb3600 100644 --- a/Doc/library/trace.rst +++ b/Doc/library/trace.rst @@ -43,7 +43,7 @@ all Python modules imported during the execution into the current directory. Display the version of the module and exit. .. versionadded:: 3.8 - Added ``--module`` option that allows to run an executable module. + Added ``--module`` option that allows running an executable module. Main options ^^^^^^^^^^^^ diff --git a/Doc/library/tracemalloc.rst b/Doc/library/tracemalloc.rst index d11ad11bbb008b..0fa70389f1f577 100644 --- a/Doc/library/tracemalloc.rst +++ b/Doc/library/tracemalloc.rst @@ -589,7 +589,7 @@ Snapshot If *cumulative* is ``True``, cumulate size and count of memory blocks of all frames of the traceback of a trace, not only the most recent frame. - The cumulative mode can only be used with *key_type* equals to + The cumulative mode can only be used with *key_type* equal to ``'filename'`` and ``'lineno'``. The result is sorted from the biggest to the smallest by: @@ -720,11 +720,10 @@ Traceback When a snapshot is taken, tracebacks of traces are limited to :func:`get_traceback_limit` frames. See the :func:`take_snapshot` function. The original number of frames of the traceback is stored in the - :attr:`Traceback.total_nframe` attribute. That allows to know if a traceback + :attr:`Traceback.total_nframe` attribute. That allows one to know if a traceback has been truncated by the traceback limit. - The :attr:`Trace.traceback` attribute is an instance of :class:`Traceback` - instance. + The :attr:`Trace.traceback` attribute is a :class:`Traceback` instance. .. versionchanged:: 3.7 Frames are now sorted from the oldest to the most recent, instead of most recent to oldest. diff --git a/Doc/library/turtle.rst b/Doc/library/turtle.rst index 95a57c57e71d56..bfe93bc253d4fc 100644 --- a/Doc/library/turtle.rst +++ b/Doc/library/turtle.rst @@ -2248,7 +2248,7 @@ Settings and special methods Set turtle mode ("standard", "logo" or "world") and perform reset. If mode is not given, current mode is returned. - Mode "standard" is compatible with old :mod:`turtle`. Mode "logo" is + Mode "standard" is compatible with old :mod:`!turtle`. Mode "logo" is compatible with most Logo turtle graphics. Mode "world" uses user-defined "world coordinates". **Attention**: in this mode angles appear distorted if ``x/y`` unit-ratio doesn't equal 1. @@ -2689,7 +2689,7 @@ Screen and Turtle. Python script :file:`{filename}.py`. It is intended to serve as a template for translation of the docstrings into different languages. -If you (or your students) want to use :mod:`turtle` with online help in your +If you (or your students) want to use :mod:`!turtle` with online help in your native language, you have to translate the docstrings and save the resulting file as e.g. :file:`turtle_docstringdict_german.py`. @@ -2752,7 +2752,7 @@ Short explanation of selected entries: auto``. - If you set e.g. ``language = italian`` the docstringdict :file:`turtle_docstringdict_italian.py` will be loaded at import time (if - present on the import path, e.g. in the same directory as :mod:`turtle`). + present on the import path, e.g. in the same directory as :mod:`!turtle`). - The entries *exampleturtle* and *examplescreen* define the names of these objects as they occur in the docstrings. The transformation of method-docstrings to function-docstrings will delete these names from the @@ -2761,7 +2761,7 @@ Short explanation of selected entries: switch ("no subprocess"). This will prevent :func:`exitonclick` to enter the mainloop. -There can be a :file:`turtle.cfg` file in the directory where :mod:`turtle` is +There can be a :file:`turtle.cfg` file in the directory where :mod:`!turtle` is stored and an additional one in the current working directory. The latter will override the settings of the first one. @@ -2770,13 +2770,13 @@ study it as an example and see its effects when running the demos (preferably not from within the demo-viewer). -:mod:`turtledemo` --- Demo scripts -================================== +:mod:`!turtledemo` --- Demo scripts +=================================== .. module:: turtledemo :synopsis: A viewer for example turtle scripts -The :mod:`turtledemo` package includes a set of demo scripts. These +The :mod:`!turtledemo` package includes a set of demo scripts. These scripts can be run and viewed using the supplied demo viewer as follows:: python -m turtledemo @@ -2785,11 +2785,11 @@ Alternatively, you can run the demo scripts individually. For example, :: python -m turtledemo.bytedesign -The :mod:`turtledemo` package directory contains: +The :mod:`!turtledemo` package directory contains: - A demo viewer :file:`__main__.py` which can be used to view the sourcecode of the scripts and run them at the same time. -- Multiple scripts demonstrating different features of the :mod:`turtle` +- Multiple scripts demonstrating different features of the :mod:`!turtle` module. Examples can be accessed via the Examples menu. They can also be run standalone. - A :file:`turtle.cfg` file which serves as an example of how to write diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 7b62b9208412e9..a0e396983885d2 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -813,7 +813,7 @@ For example, this conforms to :pep:`484`:: def __len__(self) -> int: ... def __iter__(self) -> Iterator[int]: ... -:pep:`544` allows to solve this problem by allowing users to write +:pep:`544` solves this problem by allowing users to write the above code without explicit base classes in the class definition, allowing ``Bucket`` to be implicitly considered a subtype of both ``Sized`` and ``Iterable[int]`` by static type checkers. This is known as diff --git a/Doc/library/urllib.parse.rst b/Doc/library/urllib.parse.rst index 0fd307068effa5..ef48addaba03e9 100644 --- a/Doc/library/urllib.parse.rst +++ b/Doc/library/urllib.parse.rst @@ -217,7 +217,7 @@ or on combining URL components into a URL string. .. versionchanged:: 3.12 Leading WHATWG C0 control and space characters are stripped from the URL. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *missing_as_none* parameter. .. _WHATWG spec: https://url.spec.whatwg.org/#concept-basic-url-parser @@ -333,7 +333,7 @@ or on combining URL components into a URL string. By default, *keep_empty* is true if *parts* is the result of the :func:`urlsplit` call with ``missing_as_none=True``. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *keep_empty* parameter. @@ -371,7 +371,7 @@ or on combining URL components into a URL string. By default, *keep_empty* is true if *parts* is the result of the :func:`urlparse` call with ``missing_as_none=True``. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *keep_empty* parameter. @@ -444,7 +444,7 @@ or on combining URL components into a URL string. .. versionchanged:: 3.2 Result is a structured object rather than a simple 2-tuple. - .. versionchanged:: next + .. versionchanged:: 3.15 Added the *missing_as_none* parameter. .. function:: unwrap(url) diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst index 83d2c8704e35d9..b857b2a235e1bd 100644 --- a/Doc/library/urllib.request.rst +++ b/Doc/library/urllib.request.rst @@ -1539,13 +1539,13 @@ some point in the future. -:mod:`urllib.response` --- Response classes used by urllib -========================================================== +:mod:`!urllib.response` --- Response classes used by urllib +=========================================================== .. module:: urllib.response :synopsis: Response classes used by urllib. -The :mod:`urllib.response` module defines functions and classes which define a +The :mod:`!urllib.response` module defines functions and classes which define a minimal file-like interface, including ``read()`` and ``readline()``. Functions defined by this module are used internally by the :mod:`!urllib.request` module. The typical response object is a :class:`urllib.response.addinfourl` instance: diff --git a/Doc/library/weakref.rst b/Doc/library/weakref.rst index 2a25ed045c68bd..6dc5f90686c778 100644 --- a/Doc/library/weakref.rst +++ b/Doc/library/weakref.rst @@ -1,7 +1,7 @@ .. _mod-weakref: -:mod:`weakref` --- Weak references -================================== +:mod:`!weakref` --- Weak references +=================================== .. module:: weakref :synopsis: Support for weak references and weak dictionaries. @@ -15,7 +15,7 @@ -------------- -The :mod:`weakref` module allows the Python programmer to create :dfn:`weak +The :mod:`!weakref` module allows the Python programmer to create :dfn:`weak references` to objects. .. When making changes to the examples in this file, be sure to update @@ -39,7 +39,7 @@ associate a name with each. If you used a Python dictionary to map names to images, or images to names, the image objects would remain alive just because they appeared as values or keys in the dictionaries. The :class:`WeakKeyDictionary` and :class:`WeakValueDictionary` classes supplied by -the :mod:`weakref` module are an alternative, using weak references to construct +the :mod:`!weakref` module are an alternative, using weak references to construct mappings that don't keep objects alive solely because they appear in the mapping objects. If, for example, an image object is a value in a :class:`WeakValueDictionary`, then when the last remaining references to that @@ -63,7 +63,7 @@ remains alive until the object is collected. Most programs should find that using one of these weak container types or :class:`finalize` is all they need -- it's not usually necessary to create your own weak references directly. The low-level machinery is -exposed by the :mod:`weakref` module for the benefit of advanced uses. +exposed by the :mod:`!weakref` module for the benefit of advanced uses. Not all objects can be weakly referenced. Objects which support weak references include class instances, functions written in Python (but not in C), instance methods, diff --git a/Doc/library/wsgiref.rst b/Doc/library/wsgiref.rst index 8e9b9ada93842f..0ace7b72d32570 100644 --- a/Doc/library/wsgiref.rst +++ b/Doc/library/wsgiref.rst @@ -13,7 +13,7 @@ .. warning:: - :mod:`wsgiref` is a reference implementation and is not recommended for + :mod:`!wsgiref` is a reference implementation and is not recommended for production. The module only implements basic security checks. The Web Server Gateway Interface (WSGI) is a standard interface between web @@ -40,8 +40,8 @@ to tutorials and other resources. .. XXX If you're just trying to write a web application... -:mod:`wsgiref.util` -- WSGI environment utilities -------------------------------------------------- +:mod:`!wsgiref.util` -- WSGI environment utilities +-------------------------------------------------- .. module:: wsgiref.util :synopsis: WSGI environment utilities. @@ -149,7 +149,7 @@ in type annotations. httpd.serve_forever() -In addition to the environment functions above, the :mod:`wsgiref.util` module +In addition to the environment functions above, the :mod:`!wsgiref.util` module also provides these miscellaneous utilities: @@ -189,8 +189,8 @@ also provides these miscellaneous utilities: Support for :meth:`~object.__getitem__` method has been removed. -:mod:`wsgiref.headers` -- WSGI response header tools ----------------------------------------------------- +:mod:`!wsgiref.headers` -- WSGI response header tools +----------------------------------------------------- .. module:: wsgiref.headers :synopsis: WSGI response header tools. @@ -273,8 +273,8 @@ manipulation of WSGI response headers using a mapping-like interface. *headers* parameter is optional. -:mod:`wsgiref.simple_server` -- a simple WSGI HTTP server ---------------------------------------------------------- +:mod:`!wsgiref.simple_server` -- a simple WSGI HTTP server +---------------------------------------------------------- .. module:: wsgiref.simple_server :synopsis: A simple WSGI HTTP server. @@ -315,7 +315,7 @@ request. (E.g., using the :func:`shift_path_info` function from This function is a small but complete WSGI application that returns a text page containing the message "Hello world!" and a list of the key/value pairs provided in the *environ* parameter. It's useful for verifying that a WSGI server (such - as :mod:`wsgiref.simple_server`) is able to run a simple WSGI application + as :mod:`!wsgiref.simple_server`) is able to run a simple WSGI application correctly. The *start_response* callable should follow the :class:`.StartResponse` protocol. @@ -387,8 +387,8 @@ request. (E.g., using the :func:`shift_path_info` function from interface. -:mod:`wsgiref.validate` --- WSGI conformance checker ----------------------------------------------------- +:mod:`!wsgiref.validate` --- WSGI conformance checker +----------------------------------------------------- .. module:: wsgiref.validate :synopsis: WSGI conformance checker. @@ -396,7 +396,7 @@ request. (E.g., using the :func:`shift_path_info` function from When creating new WSGI application objects, frameworks, servers, or middleware, it can be useful to validate the new code's conformance using -:mod:`wsgiref.validate`. This module provides a function that creates WSGI +:mod:`!wsgiref.validate`. This module provides a function that creates WSGI application objects that validate communications between a WSGI server or gateway and a WSGI application object, to check both sides for protocol conformance. @@ -455,8 +455,8 @@ Paste" library. httpd.serve_forever() -:mod:`wsgiref.handlers` -- server/gateway base classes ------------------------------------------------------- +:mod:`!wsgiref.handlers` -- server/gateway base classes +------------------------------------------------------- .. module:: wsgiref.handlers :synopsis: WSGI server/gateway base classes. @@ -627,7 +627,7 @@ input, output, and error streams. The default environment variables to be included in every request's WSGI environment. By default, this is a copy of ``os.environ`` at the time that - :mod:`wsgiref.handlers` was imported, but subclasses can either create their own + :mod:`!wsgiref.handlers` was imported, but subclasses can either create their own at the class or instance level. Note that the dictionary should be considered read-only, since the default value is shared between multiple classes and instances. @@ -778,8 +778,8 @@ input, output, and error streams. .. versionadded:: 3.2 -:mod:`wsgiref.types` -- WSGI types for static type checking ------------------------------------------------------------ +:mod:`!wsgiref.types` -- WSGI types for static type checking +------------------------------------------------------------ .. module:: wsgiref.types :synopsis: WSGI types for static type checking diff --git a/Doc/library/xml.dom.minidom.rst b/Doc/library/xml.dom.minidom.rst index f68a78e47f6aa5..321d93079bc6fa 100644 --- a/Doc/library/xml.dom.minidom.rst +++ b/Doc/library/xml.dom.minidom.rst @@ -62,7 +62,7 @@ document. What the :func:`parse` and :func:`parseString` functions do is connect an XML parser with a "DOM builder" that can accept parse events from any SAX parser and -convert them into a DOM tree. The name of the functions are perhaps misleading, +convert them into a DOM tree. The names of the functions are perhaps misleading, but are easy to grasp when learning the interfaces. The parsing of the document will be completed before these functions return; it's simply that these functions do not provide a parser implementation themselves. diff --git a/Doc/library/xml.rst b/Doc/library/xml.rst index acd8d399fe32fc..81d47147f33816 100644 --- a/Doc/library/xml.rst +++ b/Doc/library/xml.rst @@ -20,7 +20,7 @@ Python's interfaces for processing XML are grouped in the ``xml`` package. If you need to parse untrusted or unauthenticated data, see :ref:`xml-security`. -It is important to note that modules in the :mod:`xml` package require that +It is important to note that modules in the :mod:`!xml` package require that there be at least one SAX-compliant XML parser available. The Expat parser is included with Python, so the :mod:`xml.parsers.expat` module will always be available. diff --git a/Doc/library/xmlrpc.server.rst b/Doc/library/xmlrpc.server.rst index 8da8208331b8c2..9f16c470567406 100644 --- a/Doc/library/xmlrpc.server.rst +++ b/Doc/library/xmlrpc.server.rst @@ -230,7 +230,7 @@ a server allowing dotted names and registering a multicall function. Enabling the *allow_dotted_names* option allows intruders to access your module's global variables and may allow intruders to execute arbitrary code on - your machine. Only use this example only within a secure, closed network. + your machine. Only use this example within a secure, closed network. :: diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index 281d032b2a0f16..54384a8cf3fb90 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -323,7 +323,7 @@ See also :pep:`530`. asynchronous functions. Outer comprehensions implicitly become asynchronous. -.. versionchanged:: next +.. versionchanged:: 3.15 Unpacking with the ``*`` operator is now allowed in the expression. @@ -455,7 +455,7 @@ prevails. the key. Starting with 3.8, the key is evaluated before the value, as proposed by :pep:`572`. -.. versionchanged:: next +.. versionchanged:: 3.15 Unpacking with the ``**`` operator is now allowed in dictionary comprehensions. .. _genexpr: diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst index 7ab0b427a6cb52..4f7da5253f78bc 100644 --- a/Doc/tutorial/classes.rst +++ b/Doc/tutorial/classes.rst @@ -420,7 +420,7 @@ of the class:: 'Buddy' As discussed in :ref:`tut-object`, shared data can have possibly surprising -effects with involving :term:`mutable` objects such as lists and dictionaries. +effects involving :term:`mutable` objects such as lists and dictionaries. For example, the *tricks* list in the following code should not be used as a class variable because just a single list would be shared by all *Dog* instances:: diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index f3e69756401b8b..bee6cc39fafcdb 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -155,8 +155,8 @@ that takes an iterable is :func:`sum`:: 6 Later we will see more functions that return iterables and take iterables as -arguments. In chapter :ref:`tut-structures`, we will discuss in more detail about -:func:`list`. +arguments. In chapter :ref:`tut-structures`, we will discuss :func:`list` in more +detail. .. _tut-break: @@ -441,7 +441,7 @@ Several other key features of this statement: ``False`` and ``None`` are compared by identity. - Patterns may use named constants. These must be dotted names - to prevent them from being interpreted as capture variable:: + to prevent them from being interpreted as capture variables:: from enum import Enum class Color(Enum): @@ -1107,7 +1107,7 @@ Intermezzo: Coding Style Now that you are about to write longer, more complex pieces of Python, it is a good time to talk about *coding style*. Most languages can be written (or more -concise, *formatted*) in different styles; some are more readable than others. +concisely, *formatted*) in different styles; some are more readable than others. Making it easy for others to read your code is always a good idea, and adopting a nice coding style helps tremendously for that. diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst index ccad53a5b2d33b..fe62ee153fe034 100644 --- a/Doc/tutorial/datastructures.rst +++ b/Doc/tutorial/datastructures.rst @@ -337,7 +337,7 @@ Unpacking in Lists and List Comprehensions ------------------------------------------ The section on :ref:`tut-unpacking-arguments` describes the use of ``*`` to -"unpack" the elements of an iterable object, providing each one seperately as +"unpack" the elements of an iterable object, providing each one separately as an argument to a function. Unpacking can also be used in other contexts, for example, when creating lists. When specifying elements of a list, prefixing an expression by a ``*`` will unpack the result of that expression, adding each of diff --git a/Doc/tutorial/whatnow.rst b/Doc/tutorial/whatnow.rst index 359cf80a7b2ecf..aae8f29b007762 100644 --- a/Doc/tutorial/whatnow.rst +++ b/Doc/tutorial/whatnow.rst @@ -68,6 +68,6 @@ already contain the solution for your problem. .. rubric:: Footnotes -.. [#] "Cheese Shop" is a Monty Python's sketch: a customer enters a cheese shop, +.. [#] "Cheese Shop" is a Monty Python sketch: a customer enters a cheese shop, but whatever cheese he asks for, the clerk says it's missing. diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index c97058119ae838..515424424c1773 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -1105,7 +1105,7 @@ conflict. and kill the process. Only enable this in environments where the huge-page pool is properly sized and fork-safety is not a concern. - .. versionadded:: next + .. versionadded:: 3.15 .. envvar:: PYTHONLEGACYWINDOWSFSENCODING diff --git a/Include/cpython/object.h b/Include/cpython/object.h index 28c909531dba64..61cdb93d1d5354 100644 --- a/Include/cpython/object.h +++ b/Include/cpython/object.h @@ -493,3 +493,5 @@ PyAPI_FUNC(int) PyUnstable_TryIncRef(PyObject *); PyAPI_FUNC(void) PyUnstable_EnableTryIncRef(PyObject *); PyAPI_FUNC(int) PyUnstable_Object_IsUniquelyReferenced(PyObject *); + +PyAPI_FUNC(int) PyUnstable_SetImmortal(PyObject *op); diff --git a/Include/patchlevel.h b/Include/patchlevel.h index ea42c123116959..50d5ac4a73c1d8 100644 --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -24,10 +24,10 @@ #define PY_MINOR_VERSION 15 #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA -#define PY_RELEASE_SERIAL 5 +#define PY_RELEASE_SERIAL 6 /* Version as a string */ -#define PY_VERSION "3.15.0a5+" +#define PY_VERSION "3.15.0a6+" /*--end constants--*/ diff --git a/Lib/pydoc_data/module_docs.py b/Lib/pydoc_data/module_docs.py index f6d84a60b43a12..76a2c18bdb2f0e 100644 --- a/Lib/pydoc_data/module_docs.py +++ b/Lib/pydoc_data/module_docs.py @@ -1,4 +1,4 @@ -# Autogenerated by Sphinx on Sun Oct 12 12:02:22 2025 +# Autogenerated by Sphinx on Wed Feb 11 14:22:57 2026 # as part of the release process. module_docs = { @@ -23,7 +23,6 @@ 'bisect': 'bisect#module-bisect', 'builtins': 'builtins#module-builtins', 'bz2': 'bz2#module-bz2', - 'cProfile': 'profile#module-cProfile', 'calendar': 'calendar#module-calendar', 'cgi': 'cgi#module-cgi', 'cgitb': 'cgitb#module-cgitb', @@ -149,6 +148,7 @@ 'mailcap': 'mailcap#module-mailcap', 'marshal': 'marshal#module-marshal', 'math': 'math#module-math', + 'math.integer': 'math.integer#module-math.integer', 'mimetypes': 'mimetypes#module-mimetypes', 'mmap': 'mmap#module-mmap', 'modulefinder': 'modulefinder#module-modulefinder', @@ -183,8 +183,10 @@ 'posix': 'posix#module-posix', 'pprint': 'pprint#module-pprint', 'profile': 'profile#module-profile', - 'profiling.sampling': 'profile#module-profiling.sampling', - 'pstats': 'profile#module-pstats', + 'profiling': 'profiling#module-profiling', + 'profiling.sampling': 'profiling.sampling#module-profiling.sampling', + 'profiling.tracing': 'profiling.tracing#module-profiling.tracing', + 'pstats': 'pstats#module-pstats', 'pty': 'pty#module-pty', 'pwd': 'pwd#module-pwd', 'py_compile': 'py_compile#module-py_compile', diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py index e2d3a5184d87d5..32cf9a995bae3d 100644 --- a/Lib/pydoc_data/topics.py +++ b/Lib/pydoc_data/topics.py @@ -1,4 +1,4 @@ -# Autogenerated by Sphinx on Wed Jan 14 16:41:25 2026 +# Autogenerated by Sphinx on Wed Feb 11 14:22:57 2026 # as part of the release process. topics = { @@ -46,11 +46,10 @@ | "[" [target_list] "]" | attributeref | subscription - | slicing | "*" target -(See section Primaries for the syntax definitions for *attributeref*, -*subscription*, and *slicing*.) +(See section Primaries for the syntax definitions for *attributeref* +and *subscription*.) An assignment statement evaluates the expression list (remember that this can be a single expression or a comma-separated list, the latter @@ -59,12 +58,11 @@ Assignment is defined recursively depending on the form of the target (list). When a target is part of a mutable object (an attribute -reference, subscription or slicing), the mutable object must -ultimately perform the assignment and decide about its validity, and -may raise an exception if the assignment is unacceptable. The rules -observed by various types and the exceptions raised are given with the -definition of the object types (see section The standard type -hierarchy). +reference or subscription), the mutable object must ultimately perform +the assignment and decide about its validity, and may raise an +exception if the assignment is unacceptable. The rules observed by +various types and the exceptions raised are given with the definition +of the object types (see section The standard type hierarchy). Assignment of an object to a target list, optionally enclosed in parentheses or square brackets, is recursively defined as follows. @@ -130,9 +128,13 @@ class Cls: attributes, such as properties created with "property()". * If the target is a subscription: The primary expression in the - reference is evaluated. It should yield either a mutable sequence - object (such as a list) or a mapping object (such as a dictionary). - Next, the subscript expression is evaluated. + reference is evaluated. Next, the subscript expression is evaluated. + Then, the primary’s "__setitem__()" method is called with two + arguments: the subscript and the assigned object. + + Typically, "__setitem__()" is defined on mutable sequence objects + (such as lists) and mapping objects (such as dictionaries), and + behaves as follows. If the primary is a mutable sequence object (such as a list), the subscript must yield an integer. If it is negative, the sequence’s @@ -149,27 +151,17 @@ class Cls: existing key/value pair with the same key value, or insert a new key/value pair (if no key with the same value existed). - For user-defined objects, the "__setitem__()" method is called with - appropriate arguments. - -* If the target is a slicing: The primary expression in the reference - is evaluated. It should yield a mutable sequence object (such as a - list). The assigned object should be a sequence object of the same - type. Next, the lower and upper bound expressions are evaluated, - insofar they are present; defaults are zero and the sequence’s - length. The bounds should evaluate to integers. If either bound is - negative, the sequence’s length is added to it. The resulting - bounds are clipped to lie between zero and the sequence’s length, - inclusive. Finally, the sequence object is asked to replace the - slice with the items of the assigned sequence. The length of the - slice may be different from the length of the assigned sequence, - thus changing the length of the target sequence, if the target - sequence allows it. - -**CPython implementation detail:** In the current implementation, the -syntax for targets is taken to be the same as for expressions, and -invalid syntax is rejected during the code generation phase, causing -less detailed error messages. + If the target is a slicing: The primary expression should evaluate + to a mutable sequence object (such as a list). The assigned object + should be *iterable*. The slicing’s lower and upper bounds should be + integers; if they are "None" (or not present), the defaults are zero + and the sequence’s length. If either bound is negative, the + sequence’s length is added to it. The resulting bounds are clipped + to lie between zero and the sequence’s length, inclusive. Finally, + the sequence object is asked to replace the slice with the items of + the assigned sequence. The length of the slice may be different + from the length of the assigned sequence, thus changing the length + of the target sequence, if the target sequence allows it. Although the definition of assignment implies that overlaps between the left-hand side and the right-hand side are ‘simultaneous’ (for @@ -196,7 +188,7 @@ class Cls: binary operation and an assignment statement: augmented_assignment_stmt: augtarget augop (expression_list | yield_expression) - augtarget: identifier | attributeref | subscription | slicing + augtarget: identifier | attributeref | subscription augop: "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**=" | ">>=" | "<<=" | "&=" | "^=" | "|=" @@ -921,7 +913,7 @@ class to a new value, *value*. binary operation and an assignment statement: augmented_assignment_stmt: augtarget augop (expression_list | yield_expression) - augtarget: identifier | attributeref | subscription | slicing + augtarget: identifier | attributeref | subscription augop: "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**=" | ">>=" | "<<=" | "&=" | "^=" | "|=" @@ -4914,8 +4906,8 @@ def inner(x): statement in the same code block. Trying to delete an unbound name raises a "NameError" exception. -Deletion of attribute references, subscriptions and slicings is passed -to the primary object involved; deletion of a slicing is in general +Deletion of attribute references and subscriptions is passed to the +primary object involved; deletion of a slicing is in general equivalent to assignment of an empty slice of the right type (but even this is determined by the sliced object). @@ -4931,8 +4923,8 @@ def inner(x): dict_display: "{" [dict_item_list | dict_comprehension] "}" dict_item_list: dict_item ("," dict_item)* [","] + dict_comprehension: dict_item comp_for dict_item: expression ":" expression | "**" or_expr - dict_comprehension: expression ":" expression comp_for A dictionary display yields a new dictionary object. @@ -4951,11 +4943,22 @@ def inner(x): Added in version 3.5: Unpacking into dictionary displays, originally proposed by **PEP 448**. -A dict comprehension, in contrast to list and set comprehensions, -needs two expressions separated with a colon followed by the usual -“for” and “if” clauses. When the comprehension is run, the resulting -key and value elements are inserted in the new dictionary in the order -they are produced. +A dict comprehension may take one of two forms: + +* The first form uses two expressions separated with a colon followed + by the usual “for” and “if” clauses. When the comprehension is run, + the resulting key and value elements are inserted in the new + dictionary in the order they are produced. + +* The second form uses a single expression prefixed by the "**" + dictionary unpacking operator followed by the usual “for” and “if” + clauses. When the comprehension is evaluated, the expression is + evaluated and then unpacked, inserting zero or more key/value pairs + into the new dictionary. + +Both forms of dictionary comprehension retain the property that if the +same key is specified multiple times, the associated value in the +resulting dictionary will be the last one specified. Restrictions on the types of the key values are listed earlier in section The standard type hierarchy. (To summarize, the key type @@ -4967,6 +4970,9 @@ def inner(x): the evaluation order of key and value was not well-defined. In CPython, the value was evaluated before the key. Starting with 3.8, the key is evaluated before the value, as proposed by **PEP 572**. + +Changed in version 3.15.0a5 (unreleased): Unpacking with the "**" +operator is now allowed in dictionary comprehensions. ''', 'dynamic-features': r'''Interaction with dynamic features ********************************* @@ -6843,7 +6849,9 @@ def whats_on_the_telly(penguin=None): The *public names* defined by a module are determined by checking the module’s namespace for a variable named "__all__"; if defined, it must be a sequence of strings which are names defined or imported by that -module. The names given in "__all__" are all considered public and +module. Names containing non-ASCII characters must be in the +normalization form NFKC; see Non-ASCII characters in names for +details. The names given in "__all__" are all considered public and are required to exist. If "__all__" is not defined, the set of public names includes all names found in the module’s namespace which do not begin with an underscore character ("'_'"). "__all__" should contain @@ -7849,8 +7857,8 @@ class that has an "__rsub__()" method, "type(y).__rsub__(y, x)" is | value...}", "{expressions...}" | list display, dictionary display, set | | | display | +-------------------------------------------------+---------------------------------------+ -| "x[index]", "x[index:index]", | Subscription, slicing, call, | -| "x(arguments...)", "x.attribute" | attribute reference | +| "x[index]", "x[index:index]" "x(arguments...)", | Subscription (including slicing), | +| "x.attribute" | call, attribute reference | +-------------------------------------------------+---------------------------------------+ | "await x" | Await expression | +-------------------------------------------------+---------------------------------------+ @@ -8187,22 +8195,32 @@ class C: pass # a class with no methods (yet) and so forth. Missing slice items are always filled in with "None". -object.__getitem__(self, key) +object.__getitem__(self, subscript) + + Called to implement *subscription*, that is, "self[subscript]". See + Subscriptions and slicings for details on the syntax. - Called to implement evaluation of "self[key]". For *sequence* - types, the accepted keys should be integers. Optionally, they may - support "slice" objects as well. Negative index support is also - optional. If *key* is of an inappropriate type, "TypeError" may be - raised; if *key* is a value outside the set of indexes for the - sequence (after any special interpretation of negative values), - "IndexError" should be raised. For *mapping* types, if *key* is - missing (not in the container), "KeyError" should be raised. + There are two types of built-in objects that support subscription + via "__getitem__()": + + * **sequences**, where *subscript* (also called *index*) should be + an integer or a "slice" object. See the sequence documentation + for the expected behavior, including handling "slice" objects and + negative indices. + + * **mappings**, where *subscript* is also called the *key*. See + mapping documentation for the expected behavior. + + If *subscript* is of an inappropriate type, "__getitem__()" should + raise "TypeError". If *subscript* has an inappropriate value, + "__getitem__()" should raise an "LookupError" or one of its + subclasses ("IndexError" for sequences; "KeyError" for mappings). Note: - "for" loops expect that an "IndexError" will be raised for - illegal indexes to allow proper detection of the end of the - sequence. + The sequence iteration protocol (used, for example, in "for" + loops), expects that an "IndexError" will be raised for illegal + indexes to allow proper detection of the end of a sequence. Note: @@ -8292,37 +8310,40 @@ class C: pass # a class with no methods (yet) 'slicings': r'''Slicings ******** -A slicing selects a range of items in a sequence object (e.g., a -string, tuple or list). Slicings may be used as expressions or as -targets in assignment or "del" statements. The syntax for a slicing: - - slicing: primary "[" slice_list "]" - slice_list: slice_item ("," slice_item)* [","] - slice_item: expression | proper_slice - proper_slice: [lower_bound] ":" [upper_bound] [ ":" [stride] ] - lower_bound: expression - upper_bound: expression - stride: expression - -There is ambiguity in the formal syntax here: anything that looks like -an expression list also looks like a slice list, so any subscription -can be interpreted as a slicing. Rather than further complicating the -syntax, this is disambiguated by defining that in this case the -interpretation as a subscription takes priority over the -interpretation as a slicing (this is the case if the slice list -contains no proper slice). - -The semantics for a slicing are as follows. The primary is indexed -(using the same "__getitem__()" method as normal subscription) with a -key that is constructed from the slice list, as follows. If the slice -list contains at least one comma, the key is a tuple containing the -conversion of the slice items; otherwise, the conversion of the lone -slice item is the key. The conversion of a slice item that is an -expression is that expression. The conversion of a proper slice is a -slice object (see section The standard type hierarchy) whose "start", -"stop" and "step" attributes are the values of the expressions given -as lower bound, upper bound and stride, respectively, substituting -"None" for missing expressions. +A more advanced form of subscription, *slicing*, is commonly used to +extract a portion of a sequence. In this form, the subscript is a +*slice*: up to three expressions separated by colons. Any of the +expressions may be omitted, but a slice must contain at least one +colon: + + >>> number_names = ['zero', 'one', 'two', 'three', 'four', 'five'] + >>> number_names[1:3] + ['one', 'two'] + >>> number_names[1:] + ['one', 'two', 'three', 'four', 'five'] + >>> number_names[:3] + ['zero', 'one', 'two'] + >>> number_names[:] + ['zero', 'one', 'two', 'three', 'four', 'five'] + >>> number_names[::2] + ['zero', 'two', 'four'] + >>> number_names[:-3] + ['zero', 'one', 'two'] + >>> del number_names[4:] + >>> number_names + ['zero', 'one', 'two', 'three'] + +When a slice is evaluated, the interpreter constructs a "slice" object +whose "start", "stop" and "step" attributes, respectively, are the +results of the expressions between the colons. Any missing expression +evaluates to "None". This "slice" object is then passed to the +"__getitem__()" or "__class_getitem__()" *special method*, as above. + + # continuing with the SubscriptionDemo instance defined above: + >>> demo[2:3] + subscripted with: slice(2, 3, None) + >>> demo[::'spam'] + subscripted with: slice(None, None, 'spam') ''', 'specialattrs': r'''Special Attributes ****************** @@ -9557,22 +9578,32 @@ class of a class is known as that class’s *metaclass*, and most and so forth. Missing slice items are always filled in with "None". -object.__getitem__(self, key) +object.__getitem__(self, subscript) + + Called to implement *subscription*, that is, "self[subscript]". See + Subscriptions and slicings for details on the syntax. + + There are two types of built-in objects that support subscription + via "__getitem__()": - Called to implement evaluation of "self[key]". For *sequence* - types, the accepted keys should be integers. Optionally, they may - support "slice" objects as well. Negative index support is also - optional. If *key* is of an inappropriate type, "TypeError" may be - raised; if *key* is a value outside the set of indexes for the - sequence (after any special interpretation of negative values), - "IndexError" should be raised. For *mapping* types, if *key* is - missing (not in the container), "KeyError" should be raised. + * **sequences**, where *subscript* (also called *index*) should be + an integer or a "slice" object. See the sequence documentation + for the expected behavior, including handling "slice" objects and + negative indices. + + * **mappings**, where *subscript* is also called the *key*. See + mapping documentation for the expected behavior. + + If *subscript* is of an inappropriate type, "__getitem__()" should + raise "TypeError". If *subscript* has an inappropriate value, + "__getitem__()" should raise an "LookupError" or one of its + subclasses ("IndexError" for sequences; "KeyError" for mappings). Note: - "for" loops expect that an "IndexError" will be raised for - illegal indexes to allow proper detection of the end of the - sequence. + The sequence iteration protocol (used, for example, in "for" + loops), expects that an "IndexError" will be raised for illegal + indexes to allow proper detection of the end of a sequence. Note: @@ -10262,6 +10293,8 @@ class is used in a class pattern with positional arguments, each Like "find()", but raise "ValueError" when the substring is not found. For example: + >>> 'spam, spam, spam'.index('spam') + 0 >>> 'spam, spam, spam'.index('eggs') Traceback (most recent call last): File "", line 1, in @@ -10277,6 +10310,18 @@ class is used in a class pattern with positional arguments, each there is at least one character, "False" otherwise. A character "c" is alphanumeric if one of the following returns "True": "c.isalpha()", "c.isdecimal()", "c.isdigit()", or "c.isnumeric()". + For example: + + .. doctest:: + + >>> 'abc123'.isalnum() + True + >>> 'abc123!@#'.isalnum() + False + >>> ''.isalnum() + False + >>> ' '.isalnum() + False str.isalpha() @@ -10538,6 +10583,17 @@ class is used in a class pattern with positional arguments, each found, return a 3-tuple containing the string itself, followed by two empty strings. + For example: + + >>> 'Monty Python'.partition(' ') + ('Monty', ' ', 'Python') + >>> "Monty Python's Flying Circus".partition(' ') + ('Monty', ' ', "Python's Flying Circus") + >>> 'Monty Python'.partition('-') + ('Monty Python', '', '') + + See also "rpartition()". + str.removeprefix(prefix, /) If the string starts with the *prefix* string, return @@ -10600,7 +10656,18 @@ class is used in a class pattern with positional arguments, each str.rindex(sub[, start[, end]]) Like "rfind()" but raises "ValueError" when the substring *sub* is - not found. + not found. For example: + + >>> 'spam, spam, spam'.rindex('spam') + 12 + >>> 'spam, spam, spam'.rindex('eggs') + Traceback (most recent call last): + File "", line 1, in + 'spam, spam, spam'.rindex('eggs') + ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ + ValueError: substring not found + + See also "index()" and "find()". str.rjust(width, fillchar=' ', /) @@ -10617,6 +10684,17 @@ class is used in a class pattern with positional arguments, each found, return a 3-tuple containing two empty strings, followed by the string itself. + For example: + + >>> 'Monty Python'.rpartition(' ') + ('Monty', ' ', 'Python') + >>> "Monty Python's Flying Circus".rpartition(' ') + ("Monty Python's Flying", ' ', 'Circus') + >>> 'Monty Python'.rpartition('-') + ('', '', 'Monty Python') + + See also "partition()". + str.rsplit(sep=None, maxsplit=-1) Return a list of the words in the string, using *sep* as the @@ -10632,21 +10710,23 @@ class is used in a class pattern with positional arguments, each *chars* argument is a string specifying the set of characters to be removed. If omitted or "None", the *chars* argument defaults to removing whitespace. The *chars* argument is not a suffix; rather, - all combinations of its values are stripped: + all combinations of its values are stripped. For example: >>> ' spacious '.rstrip() ' spacious' >>> 'mississippi'.rstrip('ipz') 'mississ' - See "str.removesuffix()" for a method that will remove a single - suffix string rather than all of a set of characters. For example: + See "removesuffix()" for a method that will remove a single suffix + string rather than all of a set of characters. For example: >>> 'Monty Python'.rstrip(' Python') 'M' >>> 'Monty Python'.removesuffix(' Python') 'Monty' + See also "strip()". + str.split(sep=None, maxsplit=-1) Return a list of the words in the string, using *sep* as the @@ -10771,6 +10851,17 @@ class is used in a class pattern with positional arguments, each With optional *start*, test string beginning at that position. With optional *end*, stop comparing string at that position. + For example: + + >>> 'Python'.startswith('Py') + True + >>> 'a tuple of prefixes'.startswith(('at', 'a')) + True + >>> 'Python is amazing'.startswith('is', 7) + True + + See also "endswith()" and "removeprefix()". + str.strip(chars=None, /) Return a copy of the string with the leading and trailing @@ -10778,7 +10869,9 @@ class is used in a class pattern with positional arguments, each set of characters to be removed. If omitted or "None", the *chars* argument defaults to removing whitespace. The *chars* argument is not a prefix or suffix; rather, all combinations of its values are - stripped: + stripped. + + For example: >>> ' spacious '.strip() 'spacious' @@ -10789,12 +10882,16 @@ class is used in a class pattern with positional arguments, each stripped from the string. Characters are removed from the leading end until reaching a string character that is not contained in the set of characters in *chars*. A similar action takes place on the - trailing end. For example: + trailing end. + + For example: >>> comment_string = '#....... Section 3.2.1 Issue #32 .......' >>> comment_string.strip('.#! ') 'Section 3.2.1 Issue #32' + See also "rstrip()". + str.swapcase() Return a copy of the string with uppercase characters converted to @@ -10851,6 +10948,12 @@ class is used in a class pattern with positional arguments, each You can use "str.maketrans()" to create a translation map from character-to-character mappings in different formats. + The following example uses a mapping to replace "'a'" with "'X'", + "'b'" with "'Y'", and delete "'c'": + + >>> 'abc123'.translate({ord('a'): 'X', ord('b'): 'Y', ord('c'): None}) + 'XY123' + See also the "codecs" module for a more flexible approach to custom character mappings. @@ -11445,62 +11548,168 @@ class is used in a class pattern with positional arguments, each ''', - 'subscriptions': r'''Subscriptions -************* + 'subscriptions': r'''Subscriptions and slicings +************************** + +The *subscription* syntax is usually used for selecting an element +from a container – for example, to get a value from a "dict": + + >>> digits_by_name = {'one': 1, 'two': 2} + >>> digits_by_name['two'] # Subscripting a dictionary using the key 'two' + 2 + +In the subscription syntax, the object being subscribed – a primary – +is followed by a *subscript* in square brackets. In the simplest case, +the subscript is a single expression. -The subscription of an instance of a container class will generally -select an element from the container. The subscription of a *generic -class* will generally return a GenericAlias object. +Depending on the type of the object being subscribed, the subscript is +sometimes called a *key* (for mappings), *index* (for sequences), or +*type argument* (for *generic types*). Syntactically, these are all +equivalent: - subscription: primary "[" flexible_expression_list "]" + >>> colors = ['red', 'blue', 'green', 'black'] + >>> colors[3] # Subscripting a list using the index 3 + 'black' -When an object is subscripted, the interpreter will evaluate the -primary and the expression list. + >>> list[str] # Parameterizing the list type using the type argument str + list[str] -The primary must evaluate to an object that supports subscription. An -object may support subscription through defining one or both of -"__getitem__()" and "__class_getitem__()". When the primary is -subscripted, the evaluated result of the expression list will be -passed to one of these methods. For more details on when -"__class_getitem__" is called instead of "__getitem__", see +At runtime, the interpreter will evaluate the primary and the +subscript, and call the primary’s "__getitem__()" or +"__class_getitem__()" *special method* with the subscript as argument. +For more details on which of these methods is called, see __class_getitem__ versus __getitem__. -If the expression list contains at least one comma, or if any of the -expressions are starred, the expression list will evaluate to a -"tuple" containing the items of the expression list. Otherwise, the -expression list will evaluate to the value of the list’s sole member. - -Changed in version 3.11: Expressions in an expression list may be -starred. See **PEP 646**. - -For built-in objects, there are two types of objects that support -subscription via "__getitem__()": - -1. Mappings. If the primary is a *mapping*, the expression list must - evaluate to an object whose value is one of the keys of the - mapping, and the subscription selects the value in the mapping that - corresponds to that key. An example of a builtin mapping class is - the "dict" class. - -2. Sequences. If the primary is a *sequence*, the expression list must - evaluate to an "int" or a "slice" (as discussed in the following - section). Examples of builtin sequence classes include the "str", - "list" and "tuple" classes. - -The formal syntax makes no special provision for negative indices in -*sequences*. However, built-in sequences all provide a "__getitem__()" -method that interprets negative indices by adding the length of the -sequence to the index so that, for example, "x[-1]" selects the last -item of "x". The resulting value must be a nonnegative integer less -than the number of items in the sequence, and the subscription selects -the item whose index is that value (counting from zero). Since the -support for negative indices and slicing occurs in the object’s -"__getitem__()" method, subclasses overriding this method will need to -explicitly add that support. - -A "string" is a special kind of sequence whose items are *characters*. -A character is not a separate data type but a string of exactly one -character. +To show how subscription works, we can define a custom object that +implements "__getitem__()" and prints out the value of the subscript: + + >>> class SubscriptionDemo: + ... def __getitem__(self, key): + ... print(f'subscripted with: {key!r}') + ... + >>> demo = SubscriptionDemo() + >>> demo[1] + subscripted with: 1 + >>> demo['a' * 3] + subscripted with: 'aaa' + +See "__getitem__()" documentation for how built-in types handle +subscription. + +Subscriptions may also be used as targets in assignment or deletion +statements. In these cases, the interpreter will call the subscripted +object’s "__setitem__()" or "__delitem__()" *special method*, +respectively, instead of "__getitem__()". + + >>> colors = ['red', 'blue', 'green', 'black'] + >>> colors[3] = 'white' # Setting item at index + >>> colors + ['red', 'blue', 'green', 'white'] + >>> del colors[3] # Deleting item at index 3 + >>> colors + ['red', 'blue', 'green'] + +All advanced forms of *subscript* documented in the following sections +are also usable for assignment and deletion. + + +Slicings +======== + +A more advanced form of subscription, *slicing*, is commonly used to +extract a portion of a sequence. In this form, the subscript is a +*slice*: up to three expressions separated by colons. Any of the +expressions may be omitted, but a slice must contain at least one +colon: + + >>> number_names = ['zero', 'one', 'two', 'three', 'four', 'five'] + >>> number_names[1:3] + ['one', 'two'] + >>> number_names[1:] + ['one', 'two', 'three', 'four', 'five'] + >>> number_names[:3] + ['zero', 'one', 'two'] + >>> number_names[:] + ['zero', 'one', 'two', 'three', 'four', 'five'] + >>> number_names[::2] + ['zero', 'two', 'four'] + >>> number_names[:-3] + ['zero', 'one', 'two'] + >>> del number_names[4:] + >>> number_names + ['zero', 'one', 'two', 'three'] + +When a slice is evaluated, the interpreter constructs a "slice" object +whose "start", "stop" and "step" attributes, respectively, are the +results of the expressions between the colons. Any missing expression +evaluates to "None". This "slice" object is then passed to the +"__getitem__()" or "__class_getitem__()" *special method*, as above. + + # continuing with the SubscriptionDemo instance defined above: + >>> demo[2:3] + subscripted with: slice(2, 3, None) + >>> demo[::'spam'] + subscripted with: slice(None, None, 'spam') + + +Comma-separated subscripts +========================== + +The subscript can also be given as two or more comma-separated +expressions or slices: + + # continuing with the SubscriptionDemo instance defined above: + >>> demo[1, 2, 3] + subscripted with: (1, 2, 3) + >>> demo[1:2, 3] + subscripted with: (slice(1, 2, None), 3) + +This form is commonly used with numerical libraries for slicing multi- +dimensional data. In this case, the interpreter constructs a "tuple" +of the results of the expressions or slices, and passes this tuple to +the "__getitem__()" or "__class_getitem__()" *special method*, as +above. + +The subscript may also be given as a single expression or slice +followed by a comma, to specify a one-element tuple: + + >>> demo['spam',] + subscripted with: ('spam',) + + +“Starred” subscriptions +======================= + +Added in version 3.11: Expressions in *tuple_slices* may be starred. +See **PEP 646**. + +The subscript can also contain a starred expression. In this case, the +interpreter unpacks the result into a tuple, and passes this tuple to +"__getitem__()" or "__class_getitem__()": + + # continuing with the SubscriptionDemo instance defined above: + >>> demo[*range(10)] + subscripted with: (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) + +Starred expressions may be combined with comma-separated expressions +and slices: + + >>> demo['a', 'b', *range(3), 'c'] + subscripted with: ('a', 'b', 0, 1, 2, 'c') + + +Formal subscription grammar +=========================== + + subscription: primary '[' subscript ']' + subscript: single_subscript | tuple_subscript + single_subscript: proper_slice | assignment_expression + proper_slice: [expression] ":" [expression] [ ":" [expression] ] + tuple_subscript: ','.(single_subscript | starred_expression)+ [','] + +Recall that the "|" operator denotes ordered choice. Specifically, in +"subscript", if both alternatives would match, the first +("single_subscript") has priority. ''', 'truth': r'''Truth Value Testing ******************* @@ -11906,10 +12115,19 @@ def foo(): "a[-2]" equals "a[n-2]", the second to last item of sequence a with length "n". -Sequences also support slicing: "a[i:j]" selects all items with index -*k* such that *i* "<=" *k* "<" *j*. When used as an expression, a -slice is a sequence of the same type. The comment above about negative -indexes also applies to negative slice positions. +The resulting value must be a nonnegative integer less than the number +of items in the sequence. If it is not, an "IndexError" is raised. + +Sequences also support slicing: "a[start:stop]" selects all items with +index *k* such that *start* "<=" *k* "<" *stop*. When used as an +expression, a slice is a sequence of the same type. The comment above +about negative subscripts also applies to negative slice positions. +Note that no error is raised if a slice position is less than zero or +larger than the length of the sequence. + +If *start* is missing or "None", slicing behaves as if *start* was +zero. If *stop* is missing or "None", slicing behaves as if *stop* was +equal to the length of the sequence. Some sequences also support “extended slicing” with a third “step” parameter: "a[i:j:k]" selects all items of *a* with index *x* where "x @@ -11930,27 +12148,33 @@ def foo(): The following types are immutable sequences: Strings - A string is a sequence of values that represent Unicode code - points. All the code points in the range "U+0000 - U+10FFFF" can be - represented in a string. Python doesn’t have a char type; instead, - every code point in the string is represented as a string object - with length "1". The built-in function "ord()" converts a code - point from its string form to an integer in the range "0 - 10FFFF"; - "chr()" converts an integer in the range "0 - 10FFFF" to the - corresponding length "1" string object. "str.encode()" can be used - to convert a "str" to "bytes" using the given text encoding, and + A string ("str") is a sequence of values that represent + *characters*, or more formally, *Unicode code points*. All the code + points in the range "0" to "0x10FFFF" can be represented in a + string. + + Python doesn’t have a dedicated *character* type. Instead, every + code point in the string is represented as a string object with + length "1". + + The built-in function "ord()" converts a code point from its string + form to an integer in the range "0" to "0x10FFFF"; "chr()" converts + an integer in the range "0" to "0x10FFFF" to the corresponding + length "1" string object. "str.encode()" can be used to convert a + "str" to "bytes" using the given text encoding, and "bytes.decode()" can be used to achieve the opposite. Tuples - The items of a tuple are arbitrary Python objects. Tuples of two or - more items are formed by comma-separated lists of expressions. A - tuple of one item (a ‘singleton’) can be formed by affixing a comma - to an expression (an expression by itself does not create a tuple, - since parentheses must be usable for grouping of expressions). An - empty tuple can be formed by an empty pair of parentheses. + The items of a "tuple" are arbitrary Python objects. Tuples of two + or more items are formed by comma-separated lists of expressions. + A tuple of one item (a ‘singleton’) can be formed by affixing a + comma to an expression (an expression by itself does not create a + tuple, since parentheses must be usable for grouping of + expressions). An empty tuple can be formed by an empty pair of + parentheses. Bytes - A bytes object is an immutable array. The items are 8-bit bytes, + A "bytes" object is an immutable array. The items are 8-bit bytes, represented by integers in the range 0 <= x < 256. Bytes literals (like "b'abc'") and the built-in "bytes()" constructor can be used to create bytes objects. Also, bytes objects can be decoded to @@ -12079,6 +12303,10 @@ def foo(): +----------------------------------------------------+----------------------------------------------------+ | Attribute | Meaning | |====================================================|====================================================| +| function.__builtins__ | A reference to the "dictionary" that holds the | +| | function’s builtins namespace. Added in version | +| | 3.10. | ++----------------------------------------------------+----------------------------------------------------+ | function.__globals__ | A reference to the "dictionary" that holds the | | | function’s global variables – the global namespace | | | of the module in which the function was defined. | diff --git a/Lib/test/.ruff.toml b/Lib/test/.ruff.toml index a1b749798fa263..7b46139f786cf7 100644 --- a/Lib/test/.ruff.toml +++ b/Lib/test/.ruff.toml @@ -1,6 +1,7 @@ extend = "../../.ruff.toml" # Inherit the project-wide settings -target-version = "py312" +# Unlike Tools/, tests can use newer syntax than PYTHON_FOR_REGEN +target-version = "py314" extend-exclude = [ # Excluded (run with the other AC files in its own separate ruff job in pre-commit) @@ -15,15 +16,6 @@ extend-exclude = [ "test_grammar.py", ] -[per-file-target-version] -# Type parameter defaults -"test_type_params.py" = "py313" - -# Template string literals -"test_annotationlib.py" = "py314" -"test_string/test_templatelib.py" = "py314" -"test_tstring.py" = "py314" - [lint] select = [ "F401", # Unused import diff --git a/Lib/test/support/import_helper.py b/Lib/test/support/import_helper.py index 093de6a82d8ca7..e8a58ed77061f5 100644 --- a/Lib/test/support/import_helper.py +++ b/Lib/test/support/import_helper.py @@ -71,7 +71,7 @@ def make_legacy_pyc(source, allow_compile=False): try: pyc_file = importlib.util.cache_from_source(source) shutil.move(pyc_file, legacy_pyc) - except (FileNotFoundError, NotImplementedError): + except FileNotFoundError, NotImplementedError: if not allow_compile: raise py_compile.compile(source, legacy_pyc, doraise=True) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 72ae7776ab9062..50938eadc8f9f3 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -8532,6 +8532,15 @@ class ThisWontWorkEither(NamedTuple): def name(self): return __class__.__name__ + def test_named_tuple_non_sequence_input(self): + field_names = ["x", "y"] + field_values = [int, int] + Point = NamedTuple("Point", zip(field_names, field_values)) + p = Point(1, 2) + self.assertEqual(p.x, 1) + self.assertEqual(p.y, 2) + self.assertEqual(repr(p),"Point(x=1, y=2)") + class TypedDictTests(BaseTestCase): def test_basics_functional_syntax(self): diff --git a/Lib/typing.py b/Lib/typing.py index 71a08a5f1df811..2dfa6d3b1499ca 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -3075,8 +3075,7 @@ class Employee(NamedTuple): """ types = {n: _type_check(t, f"field {n} annotation must be a type") for n, t in fields} - field_names = [n for n, _ in fields] - nt = _make_nmtuple(typename, field_names, _make_eager_annotate(types), module=_caller()) + nt = _make_nmtuple(typename, types, _make_eager_annotate(types), module=_caller()) nt.__orig_bases__ = (NamedTuple,) return nt diff --git a/Misc/NEWS.d/3.15.0a6.rst b/Misc/NEWS.d/3.15.0a6.rst new file mode 100644 index 00000000000000..c3e20e0f662fb2 --- /dev/null +++ b/Misc/NEWS.d/3.15.0a6.rst @@ -0,0 +1,1101 @@ +.. date: 2026-02-10-08-00-17 +.. gh-issue: 144648 +.. nonce: KEuUXp +.. release date: 2026-02-11 +.. section: macOS + +Allowed _remote_debugging to build on more OS versions by using +proc_listpids() rather than proc_listallpids(). + +.. + +.. date: 2026-02-09-23-01-49 +.. gh-issue: 124111 +.. nonce: WmQG7S +.. section: macOS + +Update macOS installer to use Tcl/Tk 9.0.3. + +.. + +.. date: 2026-02-09-22-43-47 +.. gh-issue: 144551 +.. nonce: VOfgfD +.. section: macOS + +Update macOS installer to use OpenSSL 3.5.5. + +.. + +.. date: 2026-01-05-21-36-58 +.. gh-issue: 80620 +.. nonce: p1bD58 +.. section: Windows + +Support negative timestamps in :func:`time.gmtime`, :func:`time.localtime`, +and various :mod:`datetime` functions. + +.. + +.. date: 2026-02-03-07-57-24 +.. gh-issue: 144415 +.. nonce: U3L15r +.. section: Tests + +The Android testbed now distinguishes between stdout/stderr messages which +were triggered by a newline, and those triggered by a manual call to +``flush``. This fixes logging of progress indicators and similar content. + +.. + +.. date: 2026-01-08-16-56-59 +.. gh-issue: 65784 +.. nonce: aKNo1U +.. section: Tests + +Add support for parametrized resource ``wantobjects`` in regrtests, which +allows to run Tkinter tests with the specified value of +:data:`!tkinter.wantobjects`, for example ``-u wantobjects=0``. + +.. + +.. date: 2026-01-21-12-34-05 +.. gh-issue: 144125 +.. nonce: TAz5uo +.. section: Security + +:mod:`~email.generator.BytesGenerator` will now refuse to serialize (write) +headers that are unsafely folded or delimited; see +:attr:`~email.policy.Policy.verify_generated_headers`. (Contributed by Bas +Bloemsaat and Petr Viktorin in :gh:`121650`). + +.. + +.. date: 2026-01-16-14-40-31 +.. gh-issue: 143935 +.. nonce: U2YtKl +.. section: Security + +Fixed a bug in the folding of comments when flattening an email message +using a modern email policy. Comments consisting of a very long sequence of +non-foldable characters could trigger a forced line wrap that omitted the +required leading space on the continuation line, causing the remainder of +the comment to be interpreted as a new header field. This enabled header +injection with carefully crafted inputs. + +.. + +.. date: 2026-01-16-11-51-19 +.. gh-issue: 143925 +.. nonce: mrtcHW +.. section: Security + +Reject control characters in ``data:`` URL media types. + +.. + +.. date: 2026-01-16-11-43-47 +.. gh-issue: 143923 +.. nonce: DuytMe +.. section: Security + +Reject control characters in POP3 commands. + +.. + +.. date: 2026-01-16-11-41-06 +.. gh-issue: 143921 +.. nonce: AeCOor +.. section: Security + +Reject control characters in IMAP commands. + +.. + +.. date: 2026-01-16-11-13-15 +.. gh-issue: 143919 +.. nonce: kchwZV +.. section: Security + +Reject control characters in :class:`http.cookies.Morsel` fields and values. + +.. + +.. date: 2026-01-16-11-07-36 +.. gh-issue: 143916 +.. nonce: dpWeOD +.. section: Security + +Reject C0 control characters within wsgiref.headers.Headers fields, values, +and parameters. + +.. + +.. date: 2026-02-06-23-58-54 +.. gh-issue: 144538 +.. nonce: 5_OvGv +.. section: Library + +Bump the version of pip bundled in ensurepip to version 26.0.1 + +.. + +.. date: 2026-02-05-17-15-31 +.. gh-issue: 144493 +.. nonce: XuxwVu +.. section: Library + +Improve an exception error message in ``_overlapped.BindLocal()`` that is +raised when :meth:`asyncio.loop.sock_connect` is called on a +:class:`asyncio.ProactorEventLoop` with a socket that has an invalid address +family. + +.. + +.. date: 2026-02-03-14-16-49 +.. gh-issue: 144386 +.. nonce: 9Wa59r +.. section: Library + +Add support for arbitrary descriptors :meth:`!__enter__`, :meth:`!__exit__`, +:meth:`!__aenter__`, and :meth:`!__aexit__` in :class:`contextlib.ExitStack` +and :class:`contextlib.AsyncExitStack`, for consistency with the +:keyword:`with` and :keyword:`async with` statements. + +.. + +.. date: 2026-02-03-08-50-58 +.. gh-issue: 123471 +.. nonce: yF1Gym +.. section: Library + +Make concurrent iteration over +:class:`itertools.combinations_with_replacement` and +:class:`itertools.permutations` safe under free-threading. + +.. + +.. date: 2026-02-02-12-09-38 +.. gh-issue: 74453 +.. nonce: 19h4Z5 +.. section: Library + +Deprecate :func:`os.path.commonprefix` in favor of +:func:`os.path.commonpath` for path segment prefixes. + +The :func:`os.path.commonprefix` function is being deprecated due to having +a misleading name and module. The function is not safe to use for path +prefixes despite being included in a module about path manipulation, meaning +it is easy to accidentally introduce path traversal vulnerabilities into +Python programs by using this function. + +.. + +.. date: 2026-02-01-15-25-00 +.. gh-issue: 144380 +.. nonce: U7py_s +.. section: Library + +Improve performance of :class:`io.BufferedReader` line iteration by ~49%. + +.. + +.. date: 2026-01-31-17-15-49 +.. gh-issue: 144363 +.. nonce: X9f0sU +.. section: Library + +Update bundled `libexpat `_ to 2.7.4 + +.. + +.. date: 2026-01-30-13-23-06 +.. gh-issue: 140824 +.. nonce: J1OCrC +.. section: Library + +When :mod:`faulthandler` dumps the list of third-party extension modules, +ignore sub-modules of stdlib packages. Patch by Victor Stinner. + +.. + +.. date: 2026-01-27-14-23-10 +.. gh-issue: 144206 +.. nonce: l0un4U +.. section: Library + +Improve error messages for buffer overflow in :func:`fcntl.fcntl` and +:func:`fcntl.ioctl`. + +.. + +.. date: 2026-01-27-10-02-04 +.. gh-issue: 144264 +.. nonce: Wmzbol +.. section: Library + +Speed up Base64 decoding of data containing ignored characters (both in +non-strict mode and with an explicit *ignorechars* argument). It is now up +to 2 times faster for multiline Base64 data. + +.. + +.. date: 2026-01-27-09-58-52 +.. gh-issue: 144249 +.. nonce: mCIy95 +.. section: Library + +Add filename context to :exc:`OSError` exceptions raised by +:func:`ssl.SSLContext.load_cert_chain`, allowing users to have more context. + +.. + +.. date: 2026-01-27-00-03-41 +.. gh-issue: 132888 +.. nonce: yhTfUN +.. section: Library + +Fix incorrect use of :func:`ctypes.GetLastError` and add missing error +checks for Windows API calls in :mod:`!_pyrepl.windows_console`. + +.. + +.. date: 2026-01-26-12-30-57 +.. gh-issue: 142956 +.. nonce: X9CS8J +.. section: Library + +Updated :mod:`tomllib` to parse TOML 1.1.0. + +.. + +.. date: 2026-01-25-03-23-20 +.. gh-issue: 144217 +.. nonce: E1wVXH +.. section: Library + +:mod:`mimetypes`: Add support for DICOM files (for medical imaging) with the +official MIME type ``application/dicom``. Patch by Benedikt Johannes. + +.. + +.. date: 2026-01-24-23-11-17 +.. gh-issue: 144212 +.. nonce: IXqVL8 +.. section: Library + +Mime type ``image/jxl`` is now supported by :mod:`mimetypes`. + +.. + +.. date: 2026-01-24-13-49-05 +.. gh-issue: 143594 +.. nonce: nilGlg +.. section: Library + +Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` +methods. + +.. + +.. date: 2026-01-23-06-43-21 +.. gh-issue: 144169 +.. nonce: LFy9yi +.. section: Library + +Fix three crashes when non-string keyword arguments are supplied to objects +in the :mod:`ast` module. + +.. + +.. date: 2026-01-22-10-18-17 +.. gh-issue: 144128 +.. nonce: akwY06 +.. section: Library + +Fix a crash in :meth:`array.array.fromlist` when an element's +:meth:`~object.__index__` method mutates the input list during conversion. + +.. + +.. date: 2026-01-21-19-39-07 +.. gh-issue: 144100 +.. nonce: hLMZ8Y +.. section: Library + +Fixed a crash in ctypes when using a deprecated ``POINTER(str)`` type in +``argtypes``. Instead of aborting, ctypes now raises a proper Python +exception when the pointer target type is unresolved. + +.. + +.. date: 2026-01-20-20-54-46 +.. gh-issue: 143658 +.. nonce: v8i1jE +.. section: Library + +:mod:`importlib.metadata`: Use :meth:`str.lower` and :meth:`str.replace` to +further improve performance of +:meth:`!importlib.metadata.Prepared.normalize`. Patch by Hugo van Kemenade +and Henry Schreiner. + +.. + +.. date: 2026-01-20-16-35-55 +.. gh-issue: 144050 +.. nonce: 0kKFbF +.. section: Library + +Fix :func:`stat.filemode` in the pure-Python implementation to avoid +misclassifying invalid mode values as block devices. + +.. + +.. date: 2026-01-19-16-45-16 +.. gh-issue: 83069 +.. nonce: 0TaeH9 +.. section: Library + +:meth:`subprocess.Popen.wait`: when ``timeout`` is not ``None``, an +efficient event-driven mechanism now waits for process termination, if +available. Linux >= 5.3 uses :func:`os.pidfd_open` + :func:`select.poll`. +macOS and other BSD variants use :func:`select.kqueue` + ``KQ_FILTER_PROC`` ++ ``KQ_NOTE_EXIT``. Windows keeps using ``WaitForSingleObject`` (unchanged). +If none of these mechanisms are available, the function falls back to the +traditional busy loop (non-blocking call and short sleeps). Patch by +Giampaolo Rodola. + +.. + +.. date: 2026-01-19-12-48-59 +.. gh-issue: 144030 +.. nonce: 7OK_gB +.. section: Library + +The Python implementation of :func:`functools.lru_cache` differed from the +default C implementation in that it did not check that its argument is +callable. This discrepancy is now fixed and both raise a :exc:`TypeError`. + +.. + +.. date: 2026-01-19-10-26-59 +.. gh-issue: 144001 +.. nonce: dGj8Nk +.. section: Library + +Added the *ignorechars* parameter in :func:`binascii.a2b_base64` and +:func:`base64.b64decode`. + +.. + +.. date: 2026-01-19-00-57-40 +.. gh-issue: 144023 +.. nonce: 29XUcp +.. section: Library + +Fixed validation of file descriptor 0 in posix functions when used with +follow_symlinks parameter. + +.. + +.. date: 2026-01-18-14-35-37 +.. gh-issue: 143999 +.. nonce: MneN4O +.. section: Library + +Fix an issue where :func:`inspect.getgeneratorstate` and +:func:`inspect.getcoroutinestate` could fail for generators wrapped by +:func:`types.coroutine` in the suspended state. + +.. + +.. date: 2026-01-17-07-48-27 +.. gh-issue: 143952 +.. nonce: lqJ55y +.. section: Library + +Fixed :mod:`asyncio` debugging tools to work with new remote debugging API. +Patch by Bartosz Sławecki. + +.. + +.. date: 2026-01-16-14-02-39 +.. gh-issue: 143904 +.. nonce: rErHHA +.. section: Library + +:func:`struct.pack_into` now raises OverflowError instead of IndexError for +too large *offset* argument. + +.. + +.. date: 2026-01-16-10-53-17 +.. gh-issue: 143897 +.. nonce: hWJBHN +.. section: Library + +Remove the :meth:`!isxidstart` and :meth:`!isxidcontinue` methods of +:data:`unicodedata.ucd_3_2_0`. They are now only exposed as +:func:`unicodedata.isxidstart` and :func:`unicodedata.isxidcontinue`. + +.. + +.. date: 2026-01-16-06-22-10 +.. gh-issue: 143831 +.. nonce: VLBTLp +.. section: Library + +:class:`annotationlib.ForwardRef` objects are now hashable when created from +annotation scopes with closures. Previously, hashing such objects would +throw an exception. Patch by Bartosz Sławecki. + +.. + +.. date: 2026-01-15-16-04-39 +.. gh-issue: 143874 +.. nonce: 1qQgvo +.. section: Library + +Fixed a bug in :mod:`pdb` where expression results were not sent back to +remote client. + +.. + +.. date: 2026-01-14-20-35-40 +.. gh-issue: 143754 +.. nonce: m2NQXA +.. section: Library + +Add new :mod:`tkinter` widget methods :meth:`!pack_content`, +:meth:`!place_content` and :meth:`!grid_content` which are alternative +spelling of old :meth:`!*_slaves` methods. + +.. + +.. date: 2026-01-13-16-19-50 +.. gh-issue: 143756 +.. nonce: LQOra1 +.. section: Library + +Fix potential thread safety issues in :mod:`ssl` module. + +.. + +.. date: 2026-01-13-15-56-03 +.. gh-issue: 132604 +.. nonce: lvjNTr +.. section: Library + +Previously, :class:`~typing.Protocol` classes that were not decorated with +:deco:`~typing.runtime_checkable`, but that inherited from another +``Protocol`` class that did have this decorator, could be used in +:func:`isinstance` and :func:`issubclass` checks. This behavior is now +deprecated and such checks will throw a :exc:`TypeError` in Python 3.20. +Patch by Bartosz Sławecki. + +.. + +.. date: 2026-01-13-10-38-43 +.. gh-issue: 143543 +.. nonce: DeQRCO +.. section: Library + +Fix a crash in itertools.groupby that could occur when a user-defined +:meth:`~object.__eq__` method re-enters the iterator during key comparison. + +.. + +.. date: 2026-01-11-14-14-19 +.. gh-issue: 143689 +.. nonce: fzHJ2W +.. section: Library + +Fix :meth:`io.BufferedReader.read1` state cleanup on buffer allocation +failure. + +.. + +.. date: 2026-01-09-12-37-19 +.. gh-issue: 143602 +.. nonce: V8vQpj +.. section: Library + +Fix a inconsistency issue in :meth:`~io.RawIOBase.write` that leads to +unexpected buffer overwrite by deduplicating the buffer exports. + +.. + +.. date: 2026-01-07-19-01-59 +.. gh-issue: 142434 +.. nonce: SHRS5p +.. section: Library + +Use ``ppoll()`` if available in :func:`select.poll` to have a timeout +resolution of 1 nanosecond, instead of a resolution of 1 ms. Patch by Victor +Stinner. + +.. + +.. date: 2026-01-07-11-57-59 +.. gh-issue: 140557 +.. nonce: 3P6-nW +.. section: Library + +:class:`array.array` buffers now have the same alignment when empty as when +allocated. Unaligned buffers can still be created by slicing. + +.. + +.. date: 2026-01-05-05-31-05 +.. gh-issue: 143423 +.. nonce: X7YdnR +.. section: Library + +Fix free-threaded build detection in the sampling profiler when +Py_GIL_DISABLED is set to 0. + +.. + +.. date: 2025-12-28-15-55-53 +.. gh-issue: 101178 +.. nonce: 26jYPs +.. section: Library + +Add Ascii85, Base85, and Z85 support to :mod:`binascii` and improve the +performance of the base-85 converters in :mod:`base64`. + +.. + +.. date: 2025-12-19-11-30-31 +.. gh-issue: 142966 +.. nonce: PzGiv2 +.. section: Library + +Fix :func:`!ctypes.POINTER.set_type` not updating the format string to match +the type. + +.. + +.. date: 2025-12-15-02-02-45 +.. gh-issue: 142555 +.. nonce: EC9QN_ +.. section: Library + +:mod:`array`: fix a crash in ``a[i] = v`` when converting *i* to an index +via :meth:`i.__index__ ` or :meth:`i.__float__ +` mutates the array. + +.. + +.. date: 2025-12-08-18-40-17 +.. gh-issue: 142438 +.. nonce: tH-Y16 +.. section: Library + +Fix _decimal builds configured with EXTRA_FUNCTIONALITY by correcting the +Context.apply wrapper to pass the right argument. + +.. + +.. date: 2025-11-22-20-30-00 +.. gh-issue: 141860 +.. nonce: frksvr +.. section: Library + +Add an ``on_error`` keyword-only parameter to +:func:`multiprocessing.set_forkserver_preload` to control how import +failures during module preloading are handled. Accepts ``'ignore'`` +(default, silent), ``'warn'`` (emit :exc:`ImportWarning`), or ``'fail'`` +(raise exception). Contributed by Nick Neumann and Gregory P. Smith. + +.. + +.. date: 2025-11-06-12-03-29 +.. gh-issue: 125346 +.. nonce: 7Gfpgw +.. section: Library + +Accepting ``+`` and ``/`` characters with an alternative alphabet in +:func:`base64.b64decode` and :func:`base64.urlsafe_b64decode` is now +deprecated. In future Python versions they will be errors in the strict mode +and discarded in the non-strict mode. + +.. + +.. date: 2025-10-27-00-13-04 +.. gh-issue: 140715 +.. nonce: WkozE0 +.. section: Library + +Add ``'%F'`` support to :meth:`~datetime.datetime.strptime`. + +.. + +.. date: 2024-11-27-13-11-16 +.. gh-issue: 67041 +.. nonce: ym2WKK +.. section: Library + +Add the *missing_as_none* parameter to :func:`~urllib.parse.urlparse`, +:func:`~urllib.parse.urlsplit` and :func:`~urllib.parse.urldefrag` +functions. Add the *keep_empty* parameter to +:func:`~urllib.parse.urlunparse` and :func:`~urllib.parse.urlunsplit` +functions. This allows to distinguish between empty and not defined URI +components and preserve empty components. + +.. + +.. date: 2020-07-14-23-54-18 +.. gh-issue: 77188 +.. nonce: TyI3_Q +.. section: Library + +The :mod:`pickle` module now properly handles name-mangled private methods. + +.. + +.. date: 2026-01-13-01-21-20 +.. gh-issue: 143774 +.. nonce: rqGwX1 +.. section: IDLE + +Better explain the operation of Format / Format Paragraph. + +.. + +.. date: 2026-02-10-12-08-58 +.. gh-issue: 134584 +.. nonce: P9LDy5 +.. section: Core and Builtins + +Optimize and eliminate ref-counting in ``_BINARY_OP_SUBSCR_LIST_SLICE`` + +.. + +.. date: 2026-02-08-18-13-38 +.. gh-issue: 144563 +.. nonce: hb3kpp +.. section: Core and Builtins + +Fix interaction of the Tachyon profiler and :mod:`ctypes` and other modules +that load the Python shared library (if present) in an independent map as +this was causing the mechanism that loads the binary information to be +confused. Patch by Pablo Galindo + +.. + +.. date: 2026-02-08-12-47-27 +.. gh-issue: 144601 +.. nonce: E4Yi9J +.. section: Core and Builtins + +Fix crash when importing a module whose ``PyInit`` function raises an +exception from a subinterpreter. + +.. + +.. date: 2026-02-06-17-59-47 +.. gh-issue: 144549 +.. nonce: 5BhPlY +.. section: Core and Builtins + +Fix building the tail calling interpreter on Visual Studio 2026 with +free-threading. + +.. + +.. date: 2026-02-05-13-30-00 +.. gh-issue: 144513 +.. nonce: IjSTd7 +.. section: Core and Builtins + +Fix potential deadlock when using critical sections during stop-the-world +pauses in the free-threaded build. + +.. + +.. date: 2026-02-04-12-19-48 +.. gh-issue: 131798 +.. nonce: My5jLy +.. section: Core and Builtins + +Optimise ``_GUARD_TOS_SLICE`` in the JIT. + +.. + +.. date: 2026-02-04-11-19-45 +.. gh-issue: 144330 +.. nonce: kOowSb +.. section: Core and Builtins + +Move ``classmethod`` and ``staticmethod`` initialization from ``__init__()`` +to ``__new__()``. Patch by Victor Stinner. + +.. + +.. date: 2026-02-03-17-08-13 +.. gh-issue: 144446 +.. nonce: db5619 +.. section: Core and Builtins + +Fix data races in the free-threaded build when reading frame object +attributes while another thread is executing the frame. + +.. + +.. date: 2026-02-02-17-50-14 +.. gh-issue: 120321 +.. nonce: Xfr7tL +.. section: Core and Builtins + +Add ``gi_state``, ``cr_state``, and ``ag_state`` attributes to generators, +coroutines, and async generators that return the current state as a string +(e.g., ``GEN_RUNNING``). The :mod:`inspect` module functions +:func:`~inspect.getgeneratorstate`, :func:`~inspect.getcoroutinestate`, and +:func:`~inspect.getasyncgenstate` now return these attributes directly. + +.. + +.. date: 2026-02-02-17-07-34 +.. gh-issue: 141563 +.. nonce: GheXjr +.. section: Core and Builtins + +Fix thread safety of :c:macro:`! PyDateTime_IMPORT`. + +.. + +.. date: 2026-01-30-15-54-50 +.. gh-issue: 144280 +.. nonce: kgiP5R +.. section: Core and Builtins + +Fix a bug in JIT where the predicate symbol had no truthiness + +.. + +.. date: 2026-01-30-10-38-07 +.. gh-issue: 140550 +.. nonce: Us9vPD +.. section: Core and Builtins + +In :c:member:`PyModuleDef.m_slots`, allow slots that repeat information +present in :c:type:`PyModuleDef`. + +.. + +.. date: 2026-01-29-16-57-11 +.. gh-issue: 139103 +.. nonce: icXIEQ +.. section: Core and Builtins + +Improve scaling of :func:`~collections.namedtuple` instantiation in the +free-threaded build. + +.. + +.. date: 2026-01-29-02-18-08 +.. gh-issue: 144307 +.. nonce: CLbm_o +.. section: Core and Builtins + +Prevent a reference leak in module teardown at interpreter finalization. + +.. + +.. date: 2026-01-29-01-42-14 +.. gh-issue: 144319 +.. nonce: _7EtdB +.. section: Core and Builtins + +Add huge pages support for the pymalloc allocator. Patch by Pablo Galindo + +.. + +.. date: 2026-01-27-17-49-43 +.. gh-issue: 120321 +.. nonce: Vo7c9T +.. section: Core and Builtins + +Made ``gi_yieldfrom`` thread-safe in the free-threading build by using a +lightweight lock on the frame state. + +.. + +.. date: 2026-01-23-20-20-42 +.. gh-issue: 144194 +.. nonce: IbXfxd +.. section: Core and Builtins + +Fix error handling in perf jitdump initialization on memory allocation +failure. + +.. + +.. date: 2026-01-22-17-04-30 +.. gh-issue: 143962 +.. nonce: dQR1a9 +.. section: Core and Builtins + +Name suggestion for not normalized name suggests now the normalized name or +the closest name to the normalized name. If the suggested name is not ASCII, +include also its ASCII representation. + +.. + +.. date: 2026-01-22-16-20-16 +.. gh-issue: 144157 +.. nonce: dxyp7k +.. section: Core and Builtins + +:meth:`bytes.translate` now allows the compiler to unroll its loop more +usefully for a 2x speedup in the common no-deletions specified case. + +.. + +.. date: 2026-01-21-02-30-06 +.. gh-issue: 144068 +.. nonce: 9TTu7v +.. section: Core and Builtins + +Fix JIT tracer memory leak, ensure the JIT tracer state is freed when daemon +threads are cleaned up during interpreter shutdown. + +.. + +.. date: 2026-01-19-02-33-45 +.. gh-issue: 144012 +.. nonce: wVEEWs +.. section: Core and Builtins + +Check if the result is ``NULL`` in ``BINARY_OP_EXTENT`` opcode. + +.. + +.. date: 2026-01-19-01-56-44 +.. gh-issue: 144007 +.. nonce: 1xjdBf +.. section: Core and Builtins + +Eliminate redundant refcounting in the JIT for ``BINARY_OP``. + +.. + +.. date: 2026-01-19-01-26-12 +.. gh-issue: 144005 +.. nonce: Z3O33m +.. section: Core and Builtins + +Eliminate redundant refcounting from ``BINARY_OP_EXTEND``. + +.. + +.. date: 2026-01-16-23-19-38 +.. gh-issue: 143939 +.. nonce: w9TWch +.. section: Core and Builtins + +Fix erroneous "cannot reuse already awaited coroutine" error that could +occur when a generator was run during the process of clearing a coroutine's +frame. + +.. + +.. date: 2026-01-13-22-26-49 +.. gh-issue: 141805 +.. nonce: QzIKPS +.. section: Core and Builtins + +Fix crash in :class:`set` when objects with the same hash are concurrently +added to the set after removing an element with the same hash while the set +still contains elements with the same hash. + +.. + +.. date: 2026-01-11-20-11-36 +.. gh-issue: 143670 +.. nonce: klnGoD +.. section: Core and Builtins + +Fixes a crash in ``ga_repr_items_list`` function. + +.. + +.. date: 2026-01-10-10-58-36 +.. gh-issue: 143650 +.. nonce: k8mR4x +.. section: Core and Builtins + +Fix race condition in :mod:`importlib` where a thread could receive a stale +module reference when another thread's import fails. + +.. + +.. date: 2026-01-08-14-55-31 +.. gh-issue: 143569 +.. nonce: -Ltu3c +.. section: Core and Builtins + +Generator expressions in 3.15 now conform to the documented behavior when +the iterable does not support iteration. This matches the behavior in 3.14 +and earlier + +.. + +.. date: 2025-12-29-19-31-46 +.. gh-issue: 143192 +.. nonce: JxGAyl +.. section: Core and Builtins + +Improve performance of bitwise operations on multi-digit ints. + +.. + +.. date: 2025-12-24-13-19-16 +.. gh-issue: 132657 +.. nonce: _P4DDb +.. section: Core and Builtins + +If we are specializing to ``LOAD_GLOBAL_MODULE`` or ``LOAD_ATTR_MODULE``, +try to enable deferred reference counting for the value, if the object is +owned by a different thread. This applies to the free-threaded build only +and should improve scaling of multi-threaded programs. Note that when +deferred reference counting is enabled, the object will be deallocated by +the GC, rather than by :c:func:`Py_DECREF`. + +.. + +.. date: 2025-12-21-18-12-30 +.. gh-issue: 143055 +.. nonce: PzwccL +.. section: Core and Builtins + +Implement :pep:`798` (Unpacking in Comprehensions). Patch by Adam Hartz. + +.. + +.. date: 2025-11-29-10-06-06 +.. gh-issue: 142037 +.. nonce: OpIGzK +.. section: Core and Builtins + +Improve error messages for printf-style formatting. For errors in the format +string, always include the position of the start of the format unit. For +errors related to the formatted arguments, always include the number or the +name of the argument. Raise more specific errors and include more +information (type and number of arguments, most probable causes of error). + +.. + +.. date: 2025-10-24-17-30-51 +.. gh-issue: 140557 +.. nonce: X2GETk +.. section: Core and Builtins + +:class:`bytearray` buffers now have the same alignment when empty as when +allocated. Unaligned buffers can still be created by slicing. + +.. + +.. date: 2025-10-16-22-36-05 +.. gh-issue: 140232 +.. nonce: u3srgv +.. section: Core and Builtins + +Frozenset objects with immutable elements are no longer tracked by the +garbage collector. + +.. + +.. date: 2024-02-10-05-42-26 +.. gh-issue: 115231 +.. nonce: 6T7dzi +.. section: Core and Builtins + +Setup ``__module__`` attribute for built-in static methods. Patch by Sergey +B Kirpichev. + +.. + +.. date: 2026-01-16-15-04-26 +.. gh-issue: 143869 +.. nonce: vf94km +.. section: C API + +Added :c:func:`PyLong_GetNativeLayout`, :c:struct:`PyLongLayout`, +:c:struct:`PyLongExport`, :c:func:`PyLong_Export`, +:c:func:`PyLong_FreeExport`, :c:struct:`PyLongWriter`, +:c:func:`PyLongWriter_Create`, :c:func:`PyLongWriter_Finish` and +:c:func:`PyLongWriter_Discard` to the limited API. + +.. + +.. date: 2025-12-16-18-39-30 +.. gh-issue: 141070 +.. nonce: 4EKDZ1 +.. section: C API + +Renamed :c:func:`!PyUnstable_Object_Dump` to :c:func:`PyObject_Dump`. + +.. + +.. date: 2026-02-10-06-31-29 +.. gh-issue: 140421 +.. nonce: vxosUx +.. section: Build + +Disable the perf trampoline on older macOS versions where it cannot be +built. + +.. + +.. date: 2026-01-28-19-04-12 +.. gh-issue: 144309 +.. nonce: 3sMFOh +.. section: Build + +Build Python with POSIX 2024, instead of POSIX 2008. Patch by Victor +Stinner. + +.. + +.. date: 2026-01-27-23-39-26 +.. gh-issue: 144278 +.. nonce: tejFwL +.. section: Build + +Enables defining the ``_PY_IMPL_NAME`` and ``_PY_IMPL_CACHE_TAG`` +preprocessor definitions to override :data:`sys.implementation` at build +time. Definitions need to include quotes when setting to a string literal. +Setting the cache tag to ``NULL`` has the effect of completely disabling +automatic creation and use of ``.pyc`` files. + +.. + +.. date: 2026-01-17-15-31-19 +.. gh-issue: 143960 +.. nonce: Zi0EqR +.. section: Build + +Add support for OpenSSL 3.6, drop EOL 3.2. Patch by Hugo van Kemenade. + +.. + +.. date: 2026-01-16-14-27-53 +.. gh-issue: 143941 +.. nonce: TiaE-3 +.. section: Build + +Move WASI-related files to :file:`Platforms/WASI`. Along the way, leave a +deprecated :file:`Tools/wasm/wasi/__main__.py` behind for +backwards-compatibility. + +.. + +.. date: 2026-01-15-03-36-16 +.. gh-issue: 143842 +.. nonce: EZLutl +.. section: Build + +Prevent static builds from clashing with curses by making the optimizer +COLORS table static. diff --git a/Misc/NEWS.d/next/Build/2026-01-15-03-36-16.gh-issue-143842.EZLutl.rst b/Misc/NEWS.d/next/Build/2026-01-15-03-36-16.gh-issue-143842.EZLutl.rst deleted file mode 100644 index 4d5b1146463568..00000000000000 --- a/Misc/NEWS.d/next/Build/2026-01-15-03-36-16.gh-issue-143842.EZLutl.rst +++ /dev/null @@ -1,2 +0,0 @@ -Prevent static builds from clashing with curses by making the optimizer -COLORS table static. diff --git a/Misc/NEWS.d/next/Build/2026-01-16-14-27-53.gh-issue-143941.TiaE-3.rst b/Misc/NEWS.d/next/Build/2026-01-16-14-27-53.gh-issue-143941.TiaE-3.rst deleted file mode 100644 index 68839364a0ddee..00000000000000 --- a/Misc/NEWS.d/next/Build/2026-01-16-14-27-53.gh-issue-143941.TiaE-3.rst +++ /dev/null @@ -1,3 +0,0 @@ -Move WASI-related files to :file:`Platforms/WASI`. Along the way, leave a -deprecated :file:`Tools/wasm/wasi/__main__.py` behind for -backwards-compatibility. diff --git a/Misc/NEWS.d/next/Build/2026-01-17-15-31-19.gh-issue-143960.Zi0EqR.rst b/Misc/NEWS.d/next/Build/2026-01-17-15-31-19.gh-issue-143960.Zi0EqR.rst deleted file mode 100644 index 2b8e01f937db76..00000000000000 --- a/Misc/NEWS.d/next/Build/2026-01-17-15-31-19.gh-issue-143960.Zi0EqR.rst +++ /dev/null @@ -1 +0,0 @@ -Add support for OpenSSL 3.6, drop EOL 3.2. Patch by Hugo van Kemenade. diff --git a/Misc/NEWS.d/next/Build/2026-01-27-23-39-26.gh-issue-144278.tejFwL.rst b/Misc/NEWS.d/next/Build/2026-01-27-23-39-26.gh-issue-144278.tejFwL.rst deleted file mode 100644 index 49dbdd621851f6..00000000000000 --- a/Misc/NEWS.d/next/Build/2026-01-27-23-39-26.gh-issue-144278.tejFwL.rst +++ /dev/null @@ -1,5 +0,0 @@ -Enables defining the ``_PY_IMPL_NAME`` and ``_PY_IMPL_CACHE_TAG`` preprocessor -definitions to override :data:`sys.implementation` at build time. Definitions -need to include quotes when setting to a string literal. Setting the cache tag -to ``NULL`` has the effect of completely disabling automatic creation and use of -``.pyc`` files. diff --git a/Misc/NEWS.d/next/Build/2026-01-28-19-04-12.gh-issue-144309.3sMFOh.rst b/Misc/NEWS.d/next/Build/2026-01-28-19-04-12.gh-issue-144309.3sMFOh.rst deleted file mode 100644 index c64ef494d27380..00000000000000 --- a/Misc/NEWS.d/next/Build/2026-01-28-19-04-12.gh-issue-144309.3sMFOh.rst +++ /dev/null @@ -1 +0,0 @@ -Build Python with POSIX 2024, instead of POSIX 2008. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/Build/2026-02-10-06-31-29.gh-issue-140421.vxosUx.rst b/Misc/NEWS.d/next/Build/2026-02-10-06-31-29.gh-issue-140421.vxosUx.rst deleted file mode 100644 index cab48f105cc58b..00000000000000 --- a/Misc/NEWS.d/next/Build/2026-02-10-06-31-29.gh-issue-140421.vxosUx.rst +++ /dev/null @@ -1 +0,0 @@ -Disable the perf trampoline on older macOS versions where it cannot be built. diff --git a/Misc/NEWS.d/next/C_API/2025-12-16-18-39-30.gh-issue-141070.4EKDZ1.rst b/Misc/NEWS.d/next/C_API/2025-12-16-18-39-30.gh-issue-141070.4EKDZ1.rst deleted file mode 100644 index 09ccd125995e03..00000000000000 --- a/Misc/NEWS.d/next/C_API/2025-12-16-18-39-30.gh-issue-141070.4EKDZ1.rst +++ /dev/null @@ -1 +0,0 @@ -Renamed :c:func:`!PyUnstable_Object_Dump` to :c:func:`PyObject_Dump`. diff --git a/Misc/NEWS.d/next/C_API/2026-01-16-15-04-26.gh-issue-143869.vf94km.rst b/Misc/NEWS.d/next/C_API/2026-01-16-15-04-26.gh-issue-143869.vf94km.rst deleted file mode 100644 index 60b0c1ec13062b..00000000000000 --- a/Misc/NEWS.d/next/C_API/2026-01-16-15-04-26.gh-issue-143869.vf94km.rst +++ /dev/null @@ -1,5 +0,0 @@ -Added :c:func:`PyLong_GetNativeLayout`, :c:struct:`PyLongLayout`, -:c:struct:`PyLongExport`, :c:func:`PyLong_Export`, -:c:func:`PyLong_FreeExport`, :c:struct:`PyLongWriter`, -:c:func:`PyLongWriter_Create`, :c:func:`PyLongWriter_Finish` and -:c:func:`PyLongWriter_Discard` to the limited API. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-02-10-05-42-26.gh-issue-115231.6T7dzi.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-02-10-05-42-26.gh-issue-115231.6T7dzi.rst deleted file mode 100644 index 0e41bc963bebec..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2024-02-10-05-42-26.gh-issue-115231.6T7dzi.rst +++ /dev/null @@ -1,2 +0,0 @@ -Setup ``__module__`` attribute for built-in static methods. Patch by Sergey -B Kirpichev. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-16-22-36-05.gh-issue-140232.u3srgv.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-10-16-22-36-05.gh-issue-140232.u3srgv.rst deleted file mode 100644 index e40daacbc45b7b..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-16-22-36-05.gh-issue-140232.u3srgv.rst +++ /dev/null @@ -1 +0,0 @@ -Frozenset objects with immutable elements are no longer tracked by the garbage collector. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-24-17-30-51.gh-issue-140557.X2GETk.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-10-24-17-30-51.gh-issue-140557.X2GETk.rst deleted file mode 100644 index d584279a0901b0..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-24-17-30-51.gh-issue-140557.X2GETk.rst +++ /dev/null @@ -1,2 +0,0 @@ -:class:`bytearray` buffers now have the same alignment -when empty as when allocated. Unaligned buffers can still be created by slicing. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-29-10-06-06.gh-issue-142037.OpIGzK.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-11-29-10-06-06.gh-issue-142037.OpIGzK.rst deleted file mode 100644 index 6a59be7726f254..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-11-29-10-06-06.gh-issue-142037.OpIGzK.rst +++ /dev/null @@ -1,7 +0,0 @@ -Improve error messages for printf-style formatting. -For errors in the format string, always include the position of the -start of the format unit. -For errors related to the formatted arguments, always include the number -or the name of the argument. -Raise more specific errors and include more information (type and number -of arguments, most probable causes of error). diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-12-21-18-12-30.gh-issue-143055.PzwccL.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-12-21-18-12-30.gh-issue-143055.PzwccL.rst deleted file mode 100644 index d3ed40668f6539..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-12-21-18-12-30.gh-issue-143055.PzwccL.rst +++ /dev/null @@ -1 +0,0 @@ -Implement :pep:`798` (Unpacking in Comprehensions). Patch by Adam Hartz. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-12-24-13-19-16.gh-issue-132657._P4DDb.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-12-24-13-19-16.gh-issue-132657._P4DDb.rst deleted file mode 100644 index bbc9611b748fde..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-12-24-13-19-16.gh-issue-132657._P4DDb.rst +++ /dev/null @@ -1,6 +0,0 @@ -If we are specializing to ``LOAD_GLOBAL_MODULE`` or ``LOAD_ATTR_MODULE``, try -to enable deferred reference counting for the value, if the object is owned by -a different thread. This applies to the free-threaded build only and should -improve scaling of multi-threaded programs. Note that when deferred reference -counting is enabled, the object will be deallocated by the GC, rather than by -:c:func:`Py_DECREF`. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-12-29-19-31-46.gh-issue-143192.JxGAyl.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-12-29-19-31-46.gh-issue-143192.JxGAyl.rst deleted file mode 100644 index 3a99b3d9e6a1c2..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-12-29-19-31-46.gh-issue-143192.JxGAyl.rst +++ /dev/null @@ -1 +0,0 @@ -Improve performance of bitwise operations on multi-digit ints. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-08-14-55-31.gh-issue-143569.-Ltu3c.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-08-14-55-31.gh-issue-143569.-Ltu3c.rst deleted file mode 100644 index c625c3b9a84d20..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-08-14-55-31.gh-issue-143569.-Ltu3c.rst +++ /dev/null @@ -1,3 +0,0 @@ -Generator expressions in 3.15 now conform to the documented behavior when -the iterable does not support iteration. This matches the behavior in 3.14 -and earlier diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-10-10-58-36.gh-issue-143650.k8mR4x.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-10-10-58-36.gh-issue-143650.k8mR4x.rst deleted file mode 100644 index 7bee70a828acfe..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-10-10-58-36.gh-issue-143650.k8mR4x.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix race condition in :mod:`importlib` where a thread could receive a stale -module reference when another thread's import fails. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-11-20-11-36.gh-issue-143670.klnGoD.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-11-20-11-36.gh-issue-143670.klnGoD.rst deleted file mode 100644 index 4ce0e71a47e145..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-11-20-11-36.gh-issue-143670.klnGoD.rst +++ /dev/null @@ -1 +0,0 @@ -Fixes a crash in ``ga_repr_items_list`` function. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-13-22-26-49.gh-issue-141805.QzIKPS.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-13-22-26-49.gh-issue-141805.QzIKPS.rst deleted file mode 100644 index 8878d872c5b3a7..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-13-22-26-49.gh-issue-141805.QzIKPS.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix crash in :class:`set` when objects with the same hash are concurrently -added to the set after removing an element with the same hash while the set -still contains elements with the same hash. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-16-23-19-38.gh-issue-143939.w9TWch.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-16-23-19-38.gh-issue-143939.w9TWch.rst deleted file mode 100644 index 47423663e07864..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-16-23-19-38.gh-issue-143939.w9TWch.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix erroneous "cannot reuse already awaited coroutine" error that could -occur when a generator was run during the process of clearing a coroutine's -frame. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-19-01-26-12.gh-issue-144005.Z3O33m.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-19-01-26-12.gh-issue-144005.Z3O33m.rst deleted file mode 100644 index b3582197f45dda..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-19-01-26-12.gh-issue-144005.Z3O33m.rst +++ /dev/null @@ -1 +0,0 @@ -Eliminate redundant refcounting from ``BINARY_OP_EXTEND``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-19-01-56-44.gh-issue-144007.1xjdBf.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-19-01-56-44.gh-issue-144007.1xjdBf.rst deleted file mode 100644 index 26db86fae6bf25..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-19-01-56-44.gh-issue-144007.1xjdBf.rst +++ /dev/null @@ -1 +0,0 @@ -Eliminate redundant refcounting in the JIT for ``BINARY_OP``. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-19-02-33-45.gh-issue-144012.wVEEWs.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-19-02-33-45.gh-issue-144012.wVEEWs.rst deleted file mode 100644 index 716a6e149cf885..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-19-02-33-45.gh-issue-144012.wVEEWs.rst +++ /dev/null @@ -1 +0,0 @@ -Check if the result is ``NULL`` in ``BINARY_OP_EXTENT`` opcode. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-21-02-30-06.gh-issue-144068.9TTu7v.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-21-02-30-06.gh-issue-144068.9TTu7v.rst deleted file mode 100644 index b3e5db64a368b3..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-21-02-30-06.gh-issue-144068.9TTu7v.rst +++ /dev/null @@ -1 +0,0 @@ -Fix JIT tracer memory leak, ensure the JIT tracer state is freed when daemon threads are cleaned up during interpreter shutdown. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-22-16-20-16.gh-issue-144157.dxyp7k.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-22-16-20-16.gh-issue-144157.dxyp7k.rst deleted file mode 100644 index ff62d739d7804c..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-22-16-20-16.gh-issue-144157.dxyp7k.rst +++ /dev/null @@ -1,2 +0,0 @@ -:meth:`bytes.translate` now allows the compiler to unroll its loop more -usefully for a 2x speedup in the common no-deletions specified case. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-22-17-04-30.gh-issue-143962.dQR1a9.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-22-17-04-30.gh-issue-143962.dQR1a9.rst deleted file mode 100644 index 71c2476c02b89d..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-22-17-04-30.gh-issue-143962.dQR1a9.rst +++ /dev/null @@ -1,3 +0,0 @@ -Name suggestion for not normalized name suggests now the normalized name or -the closest name to the normalized name. If the suggested name is not ASCII, -include also its ASCII representation. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-23-20-20-42.gh-issue-144194.IbXfxd.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-23-20-20-42.gh-issue-144194.IbXfxd.rst deleted file mode 100644 index 1f33284439c041..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-23-20-20-42.gh-issue-144194.IbXfxd.rst +++ /dev/null @@ -1 +0,0 @@ -Fix error handling in perf jitdump initialization on memory allocation failure. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-27-17-49-43.gh-issue-120321.Vo7c9T.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-27-17-49-43.gh-issue-120321.Vo7c9T.rst deleted file mode 100644 index 052ed07c123bcf..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-27-17-49-43.gh-issue-120321.Vo7c9T.rst +++ /dev/null @@ -1,2 +0,0 @@ -Made ``gi_yieldfrom`` thread-safe in the free-threading build -by using a lightweight lock on the frame state. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-01-42-14.gh-issue-144319._7EtdB.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-01-42-14.gh-issue-144319._7EtdB.rst deleted file mode 100644 index 805ba6067edd87..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-01-42-14.gh-issue-144319._7EtdB.rst +++ /dev/null @@ -1 +0,0 @@ -Add huge pages support for the pymalloc allocator. Patch by Pablo Galindo diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-02-18-08.gh-issue-144307.CLbm_o.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-02-18-08.gh-issue-144307.CLbm_o.rst deleted file mode 100644 index d6928e643dccd3..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-02-18-08.gh-issue-144307.CLbm_o.rst +++ /dev/null @@ -1 +0,0 @@ -Prevent a reference leak in module teardown at interpreter finalization. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-16-57-11.gh-issue-139103.icXIEQ.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-16-57-11.gh-issue-139103.icXIEQ.rst deleted file mode 100644 index de3391dfcea708..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-29-16-57-11.gh-issue-139103.icXIEQ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Improve scaling of :func:`~collections.namedtuple` instantiation in the -free-threaded build. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-30-10-38-07.gh-issue-140550.Us9vPD.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-30-10-38-07.gh-issue-140550.Us9vPD.rst deleted file mode 100644 index 7815176ec85d2d..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-30-10-38-07.gh-issue-140550.Us9vPD.rst +++ /dev/null @@ -1,2 +0,0 @@ -In :c:member:`PyModuleDef.m_slots`, allow slots that repeat information -present in :c:type:`PyModuleDef`. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-30-15-54-50.gh-issue-144280.kgiP5R.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-01-30-15-54-50.gh-issue-144280.kgiP5R.rst deleted file mode 100644 index d6a4203189063a..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-01-30-15-54-50.gh-issue-144280.kgiP5R.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a bug in JIT where the predicate symbol had no truthiness diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-02-17-07-34.gh-issue-141563.GheXjr.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-02-17-07-34.gh-issue-141563.GheXjr.rst deleted file mode 100644 index 4059525f090c50..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-02-17-07-34.gh-issue-141563.GheXjr.rst +++ /dev/null @@ -1 +0,0 @@ -Fix thread safety of :c:macro:`! PyDateTime_IMPORT`. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-02-17-50-14.gh-issue-120321.Xfr7tL.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-02-17-50-14.gh-issue-120321.Xfr7tL.rst deleted file mode 100644 index 3e868c837839e2..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-02-17-50-14.gh-issue-120321.Xfr7tL.rst +++ /dev/null @@ -1,5 +0,0 @@ -Add ``gi_state``, ``cr_state``, and ``ag_state`` attributes to generators, -coroutines, and async generators that return the current state as a string -(e.g., ``GEN_RUNNING``). The :mod:`inspect` module functions -:func:`~inspect.getgeneratorstate`, :func:`~inspect.getcoroutinestate`, and -:func:`~inspect.getasyncgenstate` now return these attributes directly. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-03-17-08-13.gh-issue-144446.db5619.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-03-17-08-13.gh-issue-144446.db5619.rst deleted file mode 100644 index 71cf49366287ae..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-03-17-08-13.gh-issue-144446.db5619.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix data races in the free-threaded build when reading frame object attributes -while another thread is executing the frame. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-04-11-19-45.gh-issue-144330.kOowSb.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-04-11-19-45.gh-issue-144330.kOowSb.rst deleted file mode 100644 index b3c61e162f4ffb..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-04-11-19-45.gh-issue-144330.kOowSb.rst +++ /dev/null @@ -1,2 +0,0 @@ -Move ``classmethod`` and ``staticmethod`` initialization from ``__init__()`` -to ``__new__()``. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-04-12-19-48.gh-issue-131798.My5jLy.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-04-12-19-48.gh-issue-131798.My5jLy.rst deleted file mode 100644 index 849889f81fc323..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-04-12-19-48.gh-issue-131798.My5jLy.rst +++ /dev/null @@ -1 +0,0 @@ -Optimise ``_GUARD_TOS_SLICE`` in the JIT. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-05-13-30-00.gh-issue-144513.IjSTd7.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-05-13-30-00.gh-issue-144513.IjSTd7.rst deleted file mode 100644 index f97160172735e1..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-05-13-30-00.gh-issue-144513.IjSTd7.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix potential deadlock when using critical sections during stop-the-world -pauses in the free-threaded build. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-06-17-59-47.gh-issue-144549.5BhPlY.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-06-17-59-47.gh-issue-144549.5BhPlY.rst deleted file mode 100644 index 9679e2cf6af426..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-06-17-59-47.gh-issue-144549.5BhPlY.rst +++ /dev/null @@ -1 +0,0 @@ -Fix building the tail calling interpreter on Visual Studio 2026 with free-threading. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-08-12-47-27.gh-issue-144601.E4Yi9J.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-08-12-47-27.gh-issue-144601.E4Yi9J.rst deleted file mode 100644 index 1c7772e2f3ca26..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-08-12-47-27.gh-issue-144601.E4Yi9J.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix crash when importing a module whose ``PyInit`` function raises an -exception from a subinterpreter. diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-08-18-13-38.gh-issue-144563.hb3kpp.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-08-18-13-38.gh-issue-144563.hb3kpp.rst deleted file mode 100644 index 023f9dce20124f..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-08-18-13-38.gh-issue-144563.hb3kpp.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix interaction of the Tachyon profiler and :mod:`ctypes` and other modules -that load the Python shared library (if present) in an independent map as -this was causing the mechanism that loads the binary information to be -confused. Patch by Pablo Galindo diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-10-12-08-58.gh-issue-134584.P9LDy5.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-10-12-08-58.gh-issue-134584.P9LDy5.rst deleted file mode 100644 index fab50180bb6219..00000000000000 --- a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-10-12-08-58.gh-issue-134584.P9LDy5.rst +++ /dev/null @@ -1 +0,0 @@ -Optimize and eliminate ref-counting in ``_BINARY_OP_SUBSCR_LIST_SLICE`` diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-02-11-13-30-11.gh-issue-143300.yjB63-.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-11-13-30-11.gh-issue-143300.yjB63-.rst new file mode 100644 index 00000000000000..85c75a224e42fc --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-02-11-13-30-11.gh-issue-143300.yjB63-.rst @@ -0,0 +1 @@ +Add :c:func:`PyUnstable_SetImmortal` C-API function to mark objects as :term:`immortal`. diff --git a/Misc/NEWS.d/next/IDLE/2026-01-13-01-21-20.gh-issue-143774.rqGwX1.rst b/Misc/NEWS.d/next/IDLE/2026-01-13-01-21-20.gh-issue-143774.rqGwX1.rst deleted file mode 100644 index dd15d1672b1b54..00000000000000 --- a/Misc/NEWS.d/next/IDLE/2026-01-13-01-21-20.gh-issue-143774.rqGwX1.rst +++ /dev/null @@ -1 +0,0 @@ -Better explain the operation of Format / Format Paragraph. diff --git a/Misc/NEWS.d/next/Library/2020-07-14-23-54-18.gh-issue-77188.TyI3_Q.rst b/Misc/NEWS.d/next/Library/2020-07-14-23-54-18.gh-issue-77188.TyI3_Q.rst deleted file mode 100644 index 3e956409d52a58..00000000000000 --- a/Misc/NEWS.d/next/Library/2020-07-14-23-54-18.gh-issue-77188.TyI3_Q.rst +++ /dev/null @@ -1 +0,0 @@ -The :mod:`pickle` module now properly handles name-mangled private methods. diff --git a/Misc/NEWS.d/next/Library/2024-11-27-13-11-16.gh-issue-67041.ym2WKK.rst b/Misc/NEWS.d/next/Library/2024-11-27-13-11-16.gh-issue-67041.ym2WKK.rst deleted file mode 100644 index 9ad1e28eac17c7..00000000000000 --- a/Misc/NEWS.d/next/Library/2024-11-27-13-11-16.gh-issue-67041.ym2WKK.rst +++ /dev/null @@ -1,6 +0,0 @@ -Add the *missing_as_none* parameter to :func:`~urllib.parse.urlparse`, -:func:`~urllib.parse.urlsplit` and :func:`~urllib.parse.urldefrag` -functions. Add the *keep_empty* parameter to -:func:`~urllib.parse.urlunparse` and :func:`~urllib.parse.urlunsplit` -functions. This allows to distinguish between empty and not defined URI -components and preserve empty components. diff --git a/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst b/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst deleted file mode 100644 index c2bb69b894c1dd..00000000000000 --- a/Misc/NEWS.d/next/Library/2025-10-27-00-13-04.gh-issue-140715.WkozE0.rst +++ /dev/null @@ -1 +0,0 @@ -Add ``'%F'`` support to :meth:`~datetime.datetime.strptime`. diff --git a/Misc/NEWS.d/next/Library/2025-11-06-12-03-29.gh-issue-125346.7Gfpgw.rst b/Misc/NEWS.d/next/Library/2025-11-06-12-03-29.gh-issue-125346.7Gfpgw.rst deleted file mode 100644 index 187a6ebbe79b26..00000000000000 --- a/Misc/NEWS.d/next/Library/2025-11-06-12-03-29.gh-issue-125346.7Gfpgw.rst +++ /dev/null @@ -1,5 +0,0 @@ -Accepting ``+`` and ``/`` characters with an alternative alphabet in -:func:`base64.b64decode` and :func:`base64.urlsafe_b64decode` is now -deprecated. -In future Python versions they will be errors in the strict mode and -discarded in the non-strict mode. diff --git a/Misc/NEWS.d/next/Library/2025-11-22-20-30-00.gh-issue-141860.frksvr.rst b/Misc/NEWS.d/next/Library/2025-11-22-20-30-00.gh-issue-141860.frksvr.rst deleted file mode 100644 index b1efd9c014f1f4..00000000000000 --- a/Misc/NEWS.d/next/Library/2025-11-22-20-30-00.gh-issue-141860.frksvr.rst +++ /dev/null @@ -1,5 +0,0 @@ -Add an ``on_error`` keyword-only parameter to -:func:`multiprocessing.set_forkserver_preload` to control how import failures -during module preloading are handled. Accepts ``'ignore'`` (default, silent), -``'warn'`` (emit :exc:`ImportWarning`), or ``'fail'`` (raise exception). -Contributed by Nick Neumann and Gregory P. Smith. diff --git a/Misc/NEWS.d/next/Library/2025-12-08-18-40-17.gh-issue-142438.tH-Y16.rst b/Misc/NEWS.d/next/Library/2025-12-08-18-40-17.gh-issue-142438.tH-Y16.rst deleted file mode 100644 index 5c1db433e1b14b..00000000000000 --- a/Misc/NEWS.d/next/Library/2025-12-08-18-40-17.gh-issue-142438.tH-Y16.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix _decimal builds configured with EXTRA_FUNCTIONALITY by correcting the -Context.apply wrapper to pass the right argument. diff --git a/Misc/NEWS.d/next/Library/2025-12-15-02-02-45.gh-issue-142555.EC9QN_.rst b/Misc/NEWS.d/next/Library/2025-12-15-02-02-45.gh-issue-142555.EC9QN_.rst deleted file mode 100644 index 72cc7c634b5750..00000000000000 --- a/Misc/NEWS.d/next/Library/2025-12-15-02-02-45.gh-issue-142555.EC9QN_.rst +++ /dev/null @@ -1,3 +0,0 @@ -:mod:`array`: fix a crash in ``a[i] = v`` when converting *i* to -an index via :meth:`i.__index__ ` or :meth:`i.__float__ -` mutates the array. diff --git a/Misc/NEWS.d/next/Library/2025-12-19-11-30-31.gh-issue-142966.PzGiv2.rst b/Misc/NEWS.d/next/Library/2025-12-19-11-30-31.gh-issue-142966.PzGiv2.rst deleted file mode 100644 index 92ea407c6b456e..00000000000000 --- a/Misc/NEWS.d/next/Library/2025-12-19-11-30-31.gh-issue-142966.PzGiv2.rst +++ /dev/null @@ -1 +0,0 @@ -Fix :func:`!ctypes.POINTER.set_type` not updating the format string to match the type. diff --git a/Misc/NEWS.d/next/Library/2025-12-28-15-55-53.gh-issue-101178.26jYPs.rst b/Misc/NEWS.d/next/Library/2025-12-28-15-55-53.gh-issue-101178.26jYPs.rst deleted file mode 100644 index 1859538896932d..00000000000000 --- a/Misc/NEWS.d/next/Library/2025-12-28-15-55-53.gh-issue-101178.26jYPs.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add Ascii85, Base85, and Z85 support to :mod:`binascii` and improve the -performance of the base-85 converters in :mod:`base64`. diff --git a/Misc/NEWS.d/next/Library/2026-01-05-05-31-05.gh-issue-143423.X7YdnR.rst b/Misc/NEWS.d/next/Library/2026-01-05-05-31-05.gh-issue-143423.X7YdnR.rst deleted file mode 100644 index d9276dfd400a5d..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-05-05-31-05.gh-issue-143423.X7YdnR.rst +++ /dev/null @@ -1 +0,0 @@ -Fix free-threaded build detection in the sampling profiler when Py_GIL_DISABLED is set to 0. diff --git a/Misc/NEWS.d/next/Library/2026-01-07-11-57-59.gh-issue-140557.3P6-nW.rst b/Misc/NEWS.d/next/Library/2026-01-07-11-57-59.gh-issue-140557.3P6-nW.rst deleted file mode 100644 index 997ad592bbaafd..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-07-11-57-59.gh-issue-140557.3P6-nW.rst +++ /dev/null @@ -1,2 +0,0 @@ -:class:`array.array` buffers now have the same alignment when empty as when -allocated. Unaligned buffers can still be created by slicing. diff --git a/Misc/NEWS.d/next/Library/2026-01-07-19-01-59.gh-issue-142434.SHRS5p.rst b/Misc/NEWS.d/next/Library/2026-01-07-19-01-59.gh-issue-142434.SHRS5p.rst deleted file mode 100644 index cb6990a463bdd9..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-07-19-01-59.gh-issue-142434.SHRS5p.rst +++ /dev/null @@ -1,3 +0,0 @@ -Use ``ppoll()`` if available in :func:`select.poll` to have a timeout -resolution of 1 nanosecond, instead of a resolution of 1 ms. Patch by Victor -Stinner. diff --git a/Misc/NEWS.d/next/Library/2026-01-09-12-37-19.gh-issue-143602.V8vQpj.rst b/Misc/NEWS.d/next/Library/2026-01-09-12-37-19.gh-issue-143602.V8vQpj.rst deleted file mode 100644 index 0eaec9029221ba..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-09-12-37-19.gh-issue-143602.V8vQpj.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a inconsistency issue in :meth:`~io.RawIOBase.write` that leads to -unexpected buffer overwrite by deduplicating the buffer exports. diff --git a/Misc/NEWS.d/next/Library/2026-01-11-14-14-19.gh-issue-143689.fzHJ2W.rst b/Misc/NEWS.d/next/Library/2026-01-11-14-14-19.gh-issue-143689.fzHJ2W.rst deleted file mode 100644 index a423b1b70ad077..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-11-14-14-19.gh-issue-143689.fzHJ2W.rst +++ /dev/null @@ -1 +0,0 @@ -Fix :meth:`io.BufferedReader.read1` state cleanup on buffer allocation failure. diff --git a/Misc/NEWS.d/next/Library/2026-01-13-10-38-43.gh-issue-143543.DeQRCO.rst b/Misc/NEWS.d/next/Library/2026-01-13-10-38-43.gh-issue-143543.DeQRCO.rst deleted file mode 100644 index 14622a395ec22e..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-13-10-38-43.gh-issue-143543.DeQRCO.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a crash in itertools.groupby that could occur when a user-defined -:meth:`~object.__eq__` method re-enters the iterator during key comparison. diff --git a/Misc/NEWS.d/next/Library/2026-01-13-15-56-03.gh-issue-132604.lvjNTr.rst b/Misc/NEWS.d/next/Library/2026-01-13-15-56-03.gh-issue-132604.lvjNTr.rst deleted file mode 100644 index 92c4dbb536cdf6..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-13-15-56-03.gh-issue-132604.lvjNTr.rst +++ /dev/null @@ -1,4 +0,0 @@ -Previously, :class:`~typing.Protocol` classes that were not decorated with :deco:`~typing.runtime_checkable`, -but that inherited from another ``Protocol`` class that did have this decorator, could be used in :func:`isinstance` -and :func:`issubclass` checks. This behavior is now deprecated and such checks will throw a :exc:`TypeError` -in Python 3.20. Patch by Bartosz Sławecki. diff --git a/Misc/NEWS.d/next/Library/2026-01-13-16-19-50.gh-issue-143756.LQOra1.rst b/Misc/NEWS.d/next/Library/2026-01-13-16-19-50.gh-issue-143756.LQOra1.rst deleted file mode 100644 index fc7eefff8619ae..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-13-16-19-50.gh-issue-143756.LQOra1.rst +++ /dev/null @@ -1 +0,0 @@ -Fix potential thread safety issues in :mod:`ssl` module. diff --git a/Misc/NEWS.d/next/Library/2026-01-14-20-35-40.gh-issue-143754.m2NQXA.rst b/Misc/NEWS.d/next/Library/2026-01-14-20-35-40.gh-issue-143754.m2NQXA.rst deleted file mode 100644 index edfdd109400d08..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-14-20-35-40.gh-issue-143754.m2NQXA.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add new :mod:`tkinter` widget methods :meth:`!pack_content`, -:meth:`!place_content` and :meth:`!grid_content` which are alternative -spelling of old :meth:`!*_slaves` methods. diff --git a/Misc/NEWS.d/next/Library/2026-01-15-16-04-39.gh-issue-143874.1qQgvo.rst b/Misc/NEWS.d/next/Library/2026-01-15-16-04-39.gh-issue-143874.1qQgvo.rst deleted file mode 100644 index a11cf715b04a8d..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-15-16-04-39.gh-issue-143874.1qQgvo.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a bug in :mod:`pdb` where expression results were not sent back to remote client. diff --git a/Misc/NEWS.d/next/Library/2026-01-16-06-22-10.gh-issue-143831.VLBTLp.rst b/Misc/NEWS.d/next/Library/2026-01-16-06-22-10.gh-issue-143831.VLBTLp.rst deleted file mode 100644 index 620adea1b6d782..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-16-06-22-10.gh-issue-143831.VLBTLp.rst +++ /dev/null @@ -1,3 +0,0 @@ -:class:`annotationlib.ForwardRef` objects are now hashable when created from -annotation scopes with closures. Previously, hashing such objects would -throw an exception. Patch by Bartosz Sławecki. diff --git a/Misc/NEWS.d/next/Library/2026-01-16-10-53-17.gh-issue-143897.hWJBHN.rst b/Misc/NEWS.d/next/Library/2026-01-16-10-53-17.gh-issue-143897.hWJBHN.rst deleted file mode 100644 index d53eac0bd356ea..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-16-10-53-17.gh-issue-143897.hWJBHN.rst +++ /dev/null @@ -1,3 +0,0 @@ -Remove the :meth:`!isxidstart` and :meth:`!isxidcontinue` methods of -:data:`unicodedata.ucd_3_2_0`. They are now only exposed as -:func:`unicodedata.isxidstart` and :func:`unicodedata.isxidcontinue`. diff --git a/Misc/NEWS.d/next/Library/2026-01-16-14-02-39.gh-issue-143904.rErHHA.rst b/Misc/NEWS.d/next/Library/2026-01-16-14-02-39.gh-issue-143904.rErHHA.rst deleted file mode 100644 index f856a4be9fc9fe..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-16-14-02-39.gh-issue-143904.rErHHA.rst +++ /dev/null @@ -1,2 +0,0 @@ -:func:`struct.pack_into` now raises OverflowError instead of IndexError for -too large *offset* argument. diff --git a/Misc/NEWS.d/next/Library/2026-01-17-07-48-27.gh-issue-143952.lqJ55y.rst b/Misc/NEWS.d/next/Library/2026-01-17-07-48-27.gh-issue-143952.lqJ55y.rst deleted file mode 100644 index 1a99d315710459..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-17-07-48-27.gh-issue-143952.lqJ55y.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fixed :mod:`asyncio` debugging tools to work with new remote debugging API. -Patch by Bartosz Sławecki. diff --git a/Misc/NEWS.d/next/Library/2026-01-18-14-35-37.gh-issue-143999.MneN4O.rst b/Misc/NEWS.d/next/Library/2026-01-18-14-35-37.gh-issue-143999.MneN4O.rst deleted file mode 100644 index dc87411aacc821..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-18-14-35-37.gh-issue-143999.MneN4O.rst +++ /dev/null @@ -1 +0,0 @@ -Fix an issue where :func:`inspect.getgeneratorstate` and :func:`inspect.getcoroutinestate` could fail for generators wrapped by :func:`types.coroutine` in the suspended state. diff --git a/Misc/NEWS.d/next/Library/2026-01-19-00-57-40.gh-issue-144023.29XUcp.rst b/Misc/NEWS.d/next/Library/2026-01-19-00-57-40.gh-issue-144023.29XUcp.rst deleted file mode 100644 index 0d06506e1ec106..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-19-00-57-40.gh-issue-144023.29XUcp.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fixed validation of file descriptor 0 in posix functions when used with -follow_symlinks parameter. diff --git a/Misc/NEWS.d/next/Library/2026-01-19-10-26-59.gh-issue-144001.dGj8Nk.rst b/Misc/NEWS.d/next/Library/2026-01-19-10-26-59.gh-issue-144001.dGj8Nk.rst deleted file mode 100644 index 02d453f4d2ceee..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-19-10-26-59.gh-issue-144001.dGj8Nk.rst +++ /dev/null @@ -1,2 +0,0 @@ -Added the *ignorechars* parameter in :func:`binascii.a2b_base64` and -:func:`base64.b64decode`. diff --git a/Misc/NEWS.d/next/Library/2026-01-19-12-48-59.gh-issue-144030.7OK_gB.rst b/Misc/NEWS.d/next/Library/2026-01-19-12-48-59.gh-issue-144030.7OK_gB.rst deleted file mode 100644 index ef3c02925405b8..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-19-12-48-59.gh-issue-144030.7OK_gB.rst +++ /dev/null @@ -1,3 +0,0 @@ -The Python implementation of :func:`functools.lru_cache` differed from the -default C implementation in that it did not check that its argument is -callable. This discrepancy is now fixed and both raise a :exc:`TypeError`. diff --git a/Misc/NEWS.d/next/Library/2026-01-19-16-45-16.gh-issue-83069.0TaeH9.rst b/Misc/NEWS.d/next/Library/2026-01-19-16-45-16.gh-issue-83069.0TaeH9.rst deleted file mode 100644 index d0d4f2bd53100f..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-19-16-45-16.gh-issue-83069.0TaeH9.rst +++ /dev/null @@ -1,7 +0,0 @@ -:meth:`subprocess.Popen.wait`: when ``timeout`` is not ``None``, an efficient -event-driven mechanism now waits for process termination, if available. Linux ->= 5.3 uses :func:`os.pidfd_open` + :func:`select.poll`. macOS and other BSD -variants use :func:`select.kqueue` + ``KQ_FILTER_PROC`` + ``KQ_NOTE_EXIT``. -Windows keeps using ``WaitForSingleObject`` (unchanged). If none of these -mechanisms are available, the function falls back to the traditional busy loop -(non-blocking call and short sleeps). Patch by Giampaolo Rodola. diff --git a/Misc/NEWS.d/next/Library/2026-01-20-16-35-55.gh-issue-144050.0kKFbF.rst b/Misc/NEWS.d/next/Library/2026-01-20-16-35-55.gh-issue-144050.0kKFbF.rst deleted file mode 100644 index dfc062d023c8f1..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-20-16-35-55.gh-issue-144050.0kKFbF.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix :func:`stat.filemode` in the pure-Python implementation to avoid misclassifying -invalid mode values as block devices. diff --git a/Misc/NEWS.d/next/Library/2026-01-20-20-54-46.gh-issue-143658.v8i1jE.rst b/Misc/NEWS.d/next/Library/2026-01-20-20-54-46.gh-issue-143658.v8i1jE.rst deleted file mode 100644 index 8935b4c655023a..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-20-20-54-46.gh-issue-143658.v8i1jE.rst +++ /dev/null @@ -1,4 +0,0 @@ -:mod:`importlib.metadata`: Use :meth:`str.lower` and :meth:`str.replace` to -further improve performance of -:meth:`!importlib.metadata.Prepared.normalize`. Patch by Hugo van Kemenade -and Henry Schreiner. diff --git a/Misc/NEWS.d/next/Library/2026-01-21-19-39-07.gh-issue-144100.hLMZ8Y.rst b/Misc/NEWS.d/next/Library/2026-01-21-19-39-07.gh-issue-144100.hLMZ8Y.rst deleted file mode 100644 index 7093b753141fb8..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-21-19-39-07.gh-issue-144100.hLMZ8Y.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fixed a crash in ctypes when using a deprecated ``POINTER(str)`` type in -``argtypes``. Instead of aborting, ctypes now raises a proper Python -exception when the pointer target type is unresolved. diff --git a/Misc/NEWS.d/next/Library/2026-01-22-10-18-17.gh-issue-144128.akwY06.rst b/Misc/NEWS.d/next/Library/2026-01-22-10-18-17.gh-issue-144128.akwY06.rst deleted file mode 100644 index 4010695aec980d..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-22-10-18-17.gh-issue-144128.akwY06.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix a crash in :meth:`array.array.fromlist` when an element's :meth:`~object.__index__` method mutates -the input list during conversion. diff --git a/Misc/NEWS.d/next/Library/2026-01-23-06-43-21.gh-issue-144169.LFy9yi.rst b/Misc/NEWS.d/next/Library/2026-01-23-06-43-21.gh-issue-144169.LFy9yi.rst deleted file mode 100644 index e2ef3d7c051d14..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-23-06-43-21.gh-issue-144169.LFy9yi.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix three crashes when non-string keyword arguments are supplied to objects -in the :mod:`ast` module. diff --git a/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst b/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst deleted file mode 100644 index e0c2c287f57271..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-24-13-49-05.gh-issue-143594.nilGlg.rst +++ /dev/null @@ -1 +0,0 @@ -Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods. diff --git a/Misc/NEWS.d/next/Library/2026-01-24-23-11-17.gh-issue-144212.IXqVL8.rst b/Misc/NEWS.d/next/Library/2026-01-24-23-11-17.gh-issue-144212.IXqVL8.rst deleted file mode 100644 index be77fb345adae3..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-24-23-11-17.gh-issue-144212.IXqVL8.rst +++ /dev/null @@ -1 +0,0 @@ -Mime type ``image/jxl`` is now supported by :mod:`mimetypes`. diff --git a/Misc/NEWS.d/next/Library/2026-01-25-03-23-20.gh-issue-144217.E1wVXH.rst b/Misc/NEWS.d/next/Library/2026-01-25-03-23-20.gh-issue-144217.E1wVXH.rst deleted file mode 100644 index d85df59b3749f1..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-25-03-23-20.gh-issue-144217.E1wVXH.rst +++ /dev/null @@ -1 +0,0 @@ -:mod:`mimetypes`: Add support for DICOM files (for medical imaging) with the official MIME type ``application/dicom``. Patch by Benedikt Johannes. diff --git a/Misc/NEWS.d/next/Library/2026-01-26-12-30-57.gh-issue-142956.X9CS8J.rst b/Misc/NEWS.d/next/Library/2026-01-26-12-30-57.gh-issue-142956.X9CS8J.rst deleted file mode 100644 index 27f104fa0b62f9..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-26-12-30-57.gh-issue-142956.X9CS8J.rst +++ /dev/null @@ -1 +0,0 @@ -Updated :mod:`tomllib` to parse TOML 1.1.0. diff --git a/Misc/NEWS.d/next/Library/2026-01-27-00-03-41.gh-issue-132888.yhTfUN.rst b/Misc/NEWS.d/next/Library/2026-01-27-00-03-41.gh-issue-132888.yhTfUN.rst deleted file mode 100644 index 71b984c69c5c29..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-27-00-03-41.gh-issue-132888.yhTfUN.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fix incorrect use of :func:`ctypes.GetLastError` and add missing error -checks for Windows API calls in :mod:`!_pyrepl.windows_console`. diff --git a/Misc/NEWS.d/next/Library/2026-01-27-09-58-52.gh-issue-144249.mCIy95.rst b/Misc/NEWS.d/next/Library/2026-01-27-09-58-52.gh-issue-144249.mCIy95.rst deleted file mode 100644 index 52f27cec478259..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-27-09-58-52.gh-issue-144249.mCIy95.rst +++ /dev/null @@ -1,2 +0,0 @@ -Add filename context to :exc:`OSError` exceptions raised by -:func:`ssl.SSLContext.load_cert_chain`, allowing users to have more context. diff --git a/Misc/NEWS.d/next/Library/2026-01-27-10-02-04.gh-issue-144264.Wmzbol.rst b/Misc/NEWS.d/next/Library/2026-01-27-10-02-04.gh-issue-144264.Wmzbol.rst deleted file mode 100644 index 11e3fdeb4355cf..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-27-10-02-04.gh-issue-144264.Wmzbol.rst +++ /dev/null @@ -1,3 +0,0 @@ -Speed up Base64 decoding of data containing ignored characters (both in -non-strict mode and with an explicit *ignorechars* argument). -It is now up to 2 times faster for multiline Base64 data. diff --git a/Misc/NEWS.d/next/Library/2026-01-27-14-23-10.gh-issue-144206.l0un4U.rst b/Misc/NEWS.d/next/Library/2026-01-27-14-23-10.gh-issue-144206.l0un4U.rst deleted file mode 100644 index 1e16d28a756296..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-27-14-23-10.gh-issue-144206.l0un4U.rst +++ /dev/null @@ -1,2 +0,0 @@ -Improve error messages for buffer overflow in :func:`fcntl.fcntl` and -:func:`fcntl.ioctl`. diff --git a/Misc/NEWS.d/next/Library/2026-01-30-13-23-06.gh-issue-140824.J1OCrC.rst b/Misc/NEWS.d/next/Library/2026-01-30-13-23-06.gh-issue-140824.J1OCrC.rst deleted file mode 100644 index dd90b6a21d135d..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-30-13-23-06.gh-issue-140824.J1OCrC.rst +++ /dev/null @@ -1,2 +0,0 @@ -When :mod:`faulthandler` dumps the list of third-party extension modules, -ignore sub-modules of stdlib packages. Patch by Victor Stinner. diff --git a/Misc/NEWS.d/next/Library/2026-01-31-17-15-49.gh-issue-144363.X9f0sU.rst b/Misc/NEWS.d/next/Library/2026-01-31-17-15-49.gh-issue-144363.X9f0sU.rst deleted file mode 100644 index c17cea6613d06b..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-01-31-17-15-49.gh-issue-144363.X9f0sU.rst +++ /dev/null @@ -1 +0,0 @@ -Update bundled `libexpat `_ to 2.7.4 diff --git a/Misc/NEWS.d/next/Library/2026-02-01-15-25-00.gh-issue-144380.U7py_s.rst b/Misc/NEWS.d/next/Library/2026-02-01-15-25-00.gh-issue-144380.U7py_s.rst deleted file mode 100644 index 4b5b1b3776d735..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-02-01-15-25-00.gh-issue-144380.U7py_s.rst +++ /dev/null @@ -1 +0,0 @@ -Improve performance of :class:`io.BufferedReader` line iteration by ~49%. diff --git a/Misc/NEWS.d/next/Library/2026-02-02-12-09-38.gh-issue-74453.19h4Z5.rst b/Misc/NEWS.d/next/Library/2026-02-02-12-09-38.gh-issue-74453.19h4Z5.rst deleted file mode 100644 index 8629c834e5b0cd..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-02-02-12-09-38.gh-issue-74453.19h4Z5.rst +++ /dev/null @@ -1,8 +0,0 @@ -Deprecate :func:`os.path.commonprefix` in favor of -:func:`os.path.commonpath` for path segment prefixes. - -The :func:`os.path.commonprefix` function is being deprecated due to -having a misleading name and module. The function is not safe to use for -path prefixes despite being included in a module about path manipulation, -meaning it is easy to accidentally introduce path traversal -vulnerabilities into Python programs by using this function. diff --git a/Misc/NEWS.d/next/Library/2026-02-03-08-50-58.gh-issue-123471.yF1Gym.rst b/Misc/NEWS.d/next/Library/2026-02-03-08-50-58.gh-issue-123471.yF1Gym.rst deleted file mode 100644 index 85e9a03426e1fc..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-02-03-08-50-58.gh-issue-123471.yF1Gym.rst +++ /dev/null @@ -1 +0,0 @@ -Make concurrent iteration over :class:`itertools.combinations_with_replacement` and :class:`itertools.permutations` safe under free-threading. diff --git a/Misc/NEWS.d/next/Library/2026-02-03-14-16-49.gh-issue-144386.9Wa59r.rst b/Misc/NEWS.d/next/Library/2026-02-03-14-16-49.gh-issue-144386.9Wa59r.rst deleted file mode 100644 index 6e60eeba208ffd..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-02-03-14-16-49.gh-issue-144386.9Wa59r.rst +++ /dev/null @@ -1,4 +0,0 @@ -Add support for arbitrary descriptors :meth:`!__enter__`, :meth:`!__exit__`, -:meth:`!__aenter__`, and :meth:`!__aexit__` in :class:`contextlib.ExitStack` -and :class:`contextlib.AsyncExitStack`, for consistency with the -:keyword:`with` and :keyword:`async with` statements. diff --git a/Misc/NEWS.d/next/Library/2026-02-05-17-15-31.gh-issue-144493.XuxwVu.rst b/Misc/NEWS.d/next/Library/2026-02-05-17-15-31.gh-issue-144493.XuxwVu.rst deleted file mode 100644 index fe205b58013af0..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-02-05-17-15-31.gh-issue-144493.XuxwVu.rst +++ /dev/null @@ -1 +0,0 @@ -Improve an exception error message in ``_overlapped.BindLocal()`` that is raised when :meth:`asyncio.loop.sock_connect` is called on a :class:`asyncio.ProactorEventLoop` with a socket that has an invalid address family. diff --git a/Misc/NEWS.d/next/Library/2026-02-06-23-58-54.gh-issue-144538.5_OvGv.rst b/Misc/NEWS.d/next/Library/2026-02-06-23-58-54.gh-issue-144538.5_OvGv.rst deleted file mode 100644 index fbded72d92551b..00000000000000 --- a/Misc/NEWS.d/next/Library/2026-02-06-23-58-54.gh-issue-144538.5_OvGv.rst +++ /dev/null @@ -1 +0,0 @@ -Bump the version of pip bundled in ensurepip to version 26.0.1 diff --git a/Misc/NEWS.d/next/Library/2026-02-08-17-09-10.gh-issue-144321.w58PhQ.rst b/Misc/NEWS.d/next/Library/2026-02-08-17-09-10.gh-issue-144321.w58PhQ.rst new file mode 100644 index 00000000000000..45561898e2e1e9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-02-08-17-09-10.gh-issue-144321.w58PhQ.rst @@ -0,0 +1,3 @@ +The functional syntax for creating :class:`typing.NamedTuple` +classes now supports passing any :term:`iterable` of fields and types. +Previously, only sequences were supported. diff --git a/Misc/NEWS.d/next/Security/2026-01-16-11-07-36.gh-issue-143916.dpWeOD.rst b/Misc/NEWS.d/next/Security/2026-01-16-11-07-36.gh-issue-143916.dpWeOD.rst deleted file mode 100644 index 44bd0b27059f94..00000000000000 --- a/Misc/NEWS.d/next/Security/2026-01-16-11-07-36.gh-issue-143916.dpWeOD.rst +++ /dev/null @@ -1,2 +0,0 @@ -Reject C0 control characters within wsgiref.headers.Headers fields, values, -and parameters. diff --git a/Misc/NEWS.d/next/Security/2026-01-16-11-13-15.gh-issue-143919.kchwZV.rst b/Misc/NEWS.d/next/Security/2026-01-16-11-13-15.gh-issue-143919.kchwZV.rst deleted file mode 100644 index 788c3e4ac2ebf7..00000000000000 --- a/Misc/NEWS.d/next/Security/2026-01-16-11-13-15.gh-issue-143919.kchwZV.rst +++ /dev/null @@ -1 +0,0 @@ -Reject control characters in :class:`http.cookies.Morsel` fields and values. diff --git a/Misc/NEWS.d/next/Security/2026-01-16-11-41-06.gh-issue-143921.AeCOor.rst b/Misc/NEWS.d/next/Security/2026-01-16-11-41-06.gh-issue-143921.AeCOor.rst deleted file mode 100644 index 4e13fe92bc60fb..00000000000000 --- a/Misc/NEWS.d/next/Security/2026-01-16-11-41-06.gh-issue-143921.AeCOor.rst +++ /dev/null @@ -1 +0,0 @@ -Reject control characters in IMAP commands. diff --git a/Misc/NEWS.d/next/Security/2026-01-16-11-43-47.gh-issue-143923.DuytMe.rst b/Misc/NEWS.d/next/Security/2026-01-16-11-43-47.gh-issue-143923.DuytMe.rst deleted file mode 100644 index 3cde4df3e0069f..00000000000000 --- a/Misc/NEWS.d/next/Security/2026-01-16-11-43-47.gh-issue-143923.DuytMe.rst +++ /dev/null @@ -1 +0,0 @@ -Reject control characters in POP3 commands. diff --git a/Misc/NEWS.d/next/Security/2026-01-16-11-51-19.gh-issue-143925.mrtcHW.rst b/Misc/NEWS.d/next/Security/2026-01-16-11-51-19.gh-issue-143925.mrtcHW.rst deleted file mode 100644 index 46109dfbef3ee7..00000000000000 --- a/Misc/NEWS.d/next/Security/2026-01-16-11-51-19.gh-issue-143925.mrtcHW.rst +++ /dev/null @@ -1 +0,0 @@ -Reject control characters in ``data:`` URL media types. diff --git a/Misc/NEWS.d/next/Security/2026-01-16-14-40-31.gh-issue-143935.U2YtKl.rst b/Misc/NEWS.d/next/Security/2026-01-16-14-40-31.gh-issue-143935.U2YtKl.rst deleted file mode 100644 index c3d864936884ac..00000000000000 --- a/Misc/NEWS.d/next/Security/2026-01-16-14-40-31.gh-issue-143935.U2YtKl.rst +++ /dev/null @@ -1,6 +0,0 @@ -Fixed a bug in the folding of comments when flattening an email message -using a modern email policy. Comments consisting of a very long sequence of -non-foldable characters could trigger a forced line wrap that omitted the -required leading space on the continuation line, causing the remainder of -the comment to be interpreted as a new header field. This enabled header -injection with carefully crafted inputs. diff --git a/Misc/NEWS.d/next/Security/2026-01-21-12-34-05.gh-issue-144125.TAz5uo.rst b/Misc/NEWS.d/next/Security/2026-01-21-12-34-05.gh-issue-144125.TAz5uo.rst deleted file mode 100644 index e6333e724972c5..00000000000000 --- a/Misc/NEWS.d/next/Security/2026-01-21-12-34-05.gh-issue-144125.TAz5uo.rst +++ /dev/null @@ -1,4 +0,0 @@ -:mod:`~email.generator.BytesGenerator` will now refuse to serialize (write) headers -that are unsafely folded or delimited; see -:attr:`~email.policy.Policy.verify_generated_headers`. (Contributed by Bas -Bloemsaat and Petr Viktorin in :gh:`121650`). diff --git a/Misc/NEWS.d/next/Tests/2026-01-08-16-56-59.gh-issue-65784.aKNo1U.rst b/Misc/NEWS.d/next/Tests/2026-01-08-16-56-59.gh-issue-65784.aKNo1U.rst deleted file mode 100644 index 7d1a153fc7a6ca..00000000000000 --- a/Misc/NEWS.d/next/Tests/2026-01-08-16-56-59.gh-issue-65784.aKNo1U.rst +++ /dev/null @@ -1,3 +0,0 @@ -Add support for parametrized resource ``wantobjects`` in regrtests, -which allows to run Tkinter tests with the specified value of -:data:`!tkinter.wantobjects`, for example ``-u wantobjects=0``. diff --git a/Misc/NEWS.d/next/Tests/2026-02-03-07-57-24.gh-issue-144415.U3L15r.rst b/Misc/NEWS.d/next/Tests/2026-02-03-07-57-24.gh-issue-144415.U3L15r.rst deleted file mode 100644 index b3a8d46329679e..00000000000000 --- a/Misc/NEWS.d/next/Tests/2026-02-03-07-57-24.gh-issue-144415.U3L15r.rst +++ /dev/null @@ -1,3 +0,0 @@ -The Android testbed now distinguishes between stdout/stderr messages which -were triggered by a newline, and those triggered by a manual call to -``flush``. This fixes logging of progress indicators and similar content. diff --git a/Misc/NEWS.d/next/Windows/2026-01-05-21-36-58.gh-issue-80620.p1bD58.rst b/Misc/NEWS.d/next/Windows/2026-01-05-21-36-58.gh-issue-80620.p1bD58.rst deleted file mode 100644 index fb2f500bc45234..00000000000000 --- a/Misc/NEWS.d/next/Windows/2026-01-05-21-36-58.gh-issue-80620.p1bD58.rst +++ /dev/null @@ -1 +0,0 @@ -Support negative timestamps in :func:`time.gmtime`, :func:`time.localtime`, and various :mod:`datetime` functions. diff --git a/Misc/NEWS.d/next/macOS/2026-02-09-22-43-47.gh-issue-144551.VOfgfD.rst b/Misc/NEWS.d/next/macOS/2026-02-09-22-43-47.gh-issue-144551.VOfgfD.rst deleted file mode 100644 index 4b979a405fd8fd..00000000000000 --- a/Misc/NEWS.d/next/macOS/2026-02-09-22-43-47.gh-issue-144551.VOfgfD.rst +++ /dev/null @@ -1 +0,0 @@ -Update macOS installer to use OpenSSL 3.5.5. diff --git a/Misc/NEWS.d/next/macOS/2026-02-09-23-01-49.gh-issue-124111.WmQG7S.rst b/Misc/NEWS.d/next/macOS/2026-02-09-23-01-49.gh-issue-124111.WmQG7S.rst deleted file mode 100644 index 1318b41478f81f..00000000000000 --- a/Misc/NEWS.d/next/macOS/2026-02-09-23-01-49.gh-issue-124111.WmQG7S.rst +++ /dev/null @@ -1 +0,0 @@ -Update macOS installer to use Tcl/Tk 9.0.3. diff --git a/Misc/NEWS.d/next/macOS/2026-02-10-08-00-17.gh-issue-144648.KEuUXp.rst b/Misc/NEWS.d/next/macOS/2026-02-10-08-00-17.gh-issue-144648.KEuUXp.rst deleted file mode 100644 index 5f8ba046f3571e..00000000000000 --- a/Misc/NEWS.d/next/macOS/2026-02-10-08-00-17.gh-issue-144648.KEuUXp.rst +++ /dev/null @@ -1 +0,0 @@ -Allowed _remote_debugging to build on more OS versions by using proc_listpids() rather than proc_listallpids(). diff --git a/Modules/_testcapi/object.c b/Modules/_testcapi/object.c index 153b28e5fe2e95..9160005e00654f 100644 --- a/Modules/_testcapi/object.c +++ b/Modules/_testcapi/object.c @@ -201,6 +201,44 @@ test_py_try_inc_ref(PyObject *self, PyObject *unused) Py_RETURN_NONE; } +static PyObject * +test_py_set_immortal(PyObject *self, PyObject *unused) +{ + // the object is allocated on C stack as otherwise, + // it would trip the refleak checker when the object + // is made immortal and leak memory, for the same + // reason we cannot call PyObject_Init() on it. + PyObject object = {0}; +#ifdef Py_GIL_DISABLED + object.ob_tid = _Py_ThreadId(); + object.ob_gc_bits = 0; + object.ob_ref_local = 1; + object.ob_ref_shared = 0; +#else + object.ob_refcnt = 1; +#endif + object.ob_type = &PyBaseObject_Type; + + assert(!PyUnstable_IsImmortal(&object)); + int rc = PyUnstable_SetImmortal(&object); + assert(rc == 1); + assert(PyUnstable_IsImmortal(&object)); + Py_DECREF(&object); // should not dealloc + assert(PyUnstable_IsImmortal(&object)); + + // Check already immortal object + rc = PyUnstable_SetImmortal(&object); + assert(rc == 0); + + // Check unicode objects + PyObject *unicode = PyUnicode_FromString("test"); + assert(!PyUnstable_IsImmortal(unicode)); + rc = PyUnstable_SetImmortal(unicode); + assert(rc == 0); + assert(!PyUnstable_IsImmortal(unicode)); + Py_DECREF(unicode); + Py_RETURN_NONE; +} static PyObject * _test_incref(PyObject *ob) @@ -528,6 +566,7 @@ static PyMethodDef test_methods[] = { {"pyobject_is_unique_temporary", pyobject_is_unique_temporary, METH_O}, {"pyobject_is_unique_temporary_new_object", pyobject_is_unique_temporary_new_object, METH_NOARGS}, {"test_py_try_inc_ref", test_py_try_inc_ref, METH_NOARGS}, + {"test_py_set_immortal", test_py_set_immortal, METH_NOARGS}, {"test_xincref_doesnt_leak",test_xincref_doesnt_leak, METH_NOARGS}, {"test_incref_doesnt_leak", test_incref_doesnt_leak, METH_NOARGS}, {"test_xdecref_doesnt_leak",test_xdecref_doesnt_leak, METH_NOARGS}, diff --git a/Objects/object.c b/Objects/object.c index a4f8ddf54b9484..1ddd949d28143e 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -2839,6 +2839,17 @@ PyUnstable_EnableTryIncRef(PyObject *op) #endif } +int +PyUnstable_SetImmortal(PyObject *op) +{ + assert(op != NULL); + if (!_PyObject_IsUniquelyReferenced(op) || PyUnicode_Check(op)) { + return 0; + } + _Py_SetImmortal(op); + return 1; +} + void _Py_ResurrectReference(PyObject *op) { diff --git a/README.rst b/README.rst index c507bf3b16ea4a..68e114e66abe43 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -This is Python version 3.15.0 alpha 5 +This is Python version 3.15.0 alpha 6 ===================================== .. image:: https://github.com/python/cpython/actions/workflows/build.yml/badge.svg?branch=main&event=push