Skip to content

Commit b2c9f29

Browse files
authored
Merge branch 'main' into docs/refwarn/whatsnew-2.7
2 parents bc0c7a8 + 8c1ae6d commit b2c9f29

33 files changed

+511
-417
lines changed

Doc/howto/instrumentation.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ should instead read:
269269
(assuming a :ref:`debug build <debug-build>` of CPython 3.6)
270270

271271

272+
.. _static-markers:
273+
272274
Available static markers
273275
------------------------
274276

Doc/library/curses.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,10 @@ The module :mod:`curses` defines the following functions:
716716
Window Objects
717717
--------------
718718

719-
Window objects, as returned by :func:`initscr` and :func:`newwin` above, have
720-
the following methods and attributes:
719+
.. class:: window
720+
721+
Window objects, as returned by :func:`initscr` and :func:`newwin` above, have
722+
the following methods and attributes:
721723

722724

723725
.. method:: window.addch(ch[, attr])

Doc/library/hmac.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ cannot be used with HMAC.
5050
.. versionadded:: 3.7
5151

5252

53-
An HMAC object has the following methods:
53+
.. class:: HMAC
54+
55+
An HMAC object has the following methods:
5456

5557
.. method:: HMAC.update(msg)
5658

Doc/library/mmap.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ update the underlying file.
4848

4949
To map anonymous memory, -1 should be passed as the fileno along with the length.
5050

51-
.. class:: mmap(fileno, length, tagname=None, access=ACCESS_DEFAULT, offset=0)
51+
.. class:: mmap(fileno, length, tagname=None, \
52+
access=ACCESS_DEFAULT, offset=0, *, trackfd=True)
5253
5354
**(Windows version)** Maps *length* bytes from the file specified by the
54-
file handle *fileno*, and creates a mmap object. If *length* is larger
55+
file descriptor *fileno*, and creates a mmap object. If *length* is larger
5556
than the current size of the file, the file is extended to contain *length*
5657
bytes. If *length* is ``0``, the maximum length of the map is the current
5758
size of the file, except that if the file is empty Windows raises an
@@ -69,6 +70,17 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
6970
will be relative to the offset from the beginning of the file. *offset*
7071
defaults to 0. *offset* must be a multiple of the :const:`ALLOCATIONGRANULARITY`.
7172

73+
If *trackfd* is ``False``, the file handle corresponding to *fileno* will
74+
not be duplicated, and the resulting :class:`!mmap` object will not
75+
be associated with the map's underlying file.
76+
This means that the :meth:`~mmap.mmap.size` and :meth:`~mmap.mmap.resize`
77+
methods will fail.
78+
This mode is useful to limit the number of open file handles.
79+
The original file can be renamed (but not deleted) after closing *fileno*.
80+
81+
.. versionchanged:: next
82+
The *trackfd* parameter was added.
83+
7284
.. audit-event:: mmap.__new__ fileno,length,access,offset mmap.mmap
7385

7486
.. class:: mmap(fileno, length, flags=MAP_SHARED, prot=PROT_WRITE|PROT_READ, \

Doc/library/xml.sax.handler.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ events in the input document:
248248

249249
The *name* parameter contains the raw XML 1.0 name of the element type as a
250250
string and the *attrs* parameter holds an object of the
251-
:class:`~xml.sax.xmlreader.Attributes`
252-
interface (see :ref:`attributes-objects`) containing the attributes of
251+
:ref:`Attributes <attributes-objects>` interface containing the attributes of
253252
the element. The object passed as *attrs* may be re-used by the parser; holding
254253
on to a reference to it is not a reliable way to keep a copy of the attributes.
255254
To keep a copy of the attributes, use the :meth:`copy` method of the *attrs*
@@ -271,8 +270,7 @@ events in the input document:
271270
The *name* parameter contains the name of the element type as a ``(uri,
272271
localname)`` tuple, the *qname* parameter contains the raw XML 1.0 name used in
273272
the source document, and the *attrs* parameter holds an instance of the
274-
:class:`~xml.sax.xmlreader.AttributesNS` interface (see
275-
:ref:`attributes-ns-objects`)
273+
:ref:`AttributesNS <attributes-ns-objects>` interface
276274
containing the attributes of the element. If no namespace is associated with
277275
the element, the *uri* component of *name* will be ``None``. The object passed
278276
as *attrs* may be re-used by the parser; holding on to a reference to it is not

Doc/reference/datamodel.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,6 +2351,9 @@ Customizing module attribute access
23512351
single: __dir__ (module attribute)
23522352
single: __class__ (module attribute)
23532353

2354+
.. method:: module.__getattr__
2355+
module.__dir__
2356+
23542357
Special names ``__getattr__`` and ``__dir__`` can be also used to customize
23552358
access to module attributes. The ``__getattr__`` function at the module level
23562359
should accept one argument which is the name of an attribute and return the
@@ -2364,6 +2367,8 @@ The ``__dir__`` function should accept no arguments, and return an iterable of
23642367
strings that represents the names accessible on module. If present, this
23652368
function overrides the standard :func:`dir` search on a module.
23662369

2370+
.. attribute:: module.__class__
2371+
23672372
For a more fine grained customization of the module behavior (setting
23682373
attributes, properties, etc.), one can set the ``__class__`` attribute of
23692374
a module object to a subclass of :class:`types.ModuleType`. For example::

Doc/tools/.nitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ Doc/library/wsgiref.rst
5050
Doc/library/xml.dom.minidom.rst
5151
Doc/library/xml.dom.pulldom.rst
5252
Doc/library/xml.dom.rst
53-
Doc/library/xml.sax.handler.rst
5453
Doc/library/xml.sax.reader.rst
5554
Doc/library/xml.sax.rst
5655
Doc/library/xmlrpc.client.rst
@@ -62,10 +61,7 @@ Doc/using/windows.rst
6261
Doc/whatsnew/2.4.rst
6362
Doc/whatsnew/2.5.rst
6463
Doc/whatsnew/2.6.rst
65-
Doc/whatsnew/3.3.rst
6664
Doc/whatsnew/3.4.rst
6765
Doc/whatsnew/3.5.rst
6866
Doc/whatsnew/3.6.rst
69-
Doc/whatsnew/3.7.rst
70-
Doc/whatsnew/3.8.rst
7167
Doc/whatsnew/3.10.rst

Doc/whatsnew/3.14.rst

Lines changed: 94 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,41 +2819,6 @@ CPython bytecode changes
28192819
* Replaced the opcode ``BINARY_SUBSCR`` by :opcode:`BINARY_OP` with oparg ``NB_SUBSCR``.
28202820
(Contributed by Irit Katriel in :gh:`100239`.)
28212821

2822-
Porting to Python 3.14
2823-
======================
2824-
2825-
This section lists previously described changes and other bugfixes
2826-
that may require changes to your code.
2827-
2828-
Changes in the Python API
2829-
-------------------------
2830-
2831-
* :class:`functools.partial` is now a method descriptor.
2832-
Wrap it in :func:`staticmethod` if you want to preserve the old behavior.
2833-
(Contributed by Serhiy Storchaka and Dominykas Grigonis in :gh:`121027`.)
2834-
2835-
* The :ref:`garbage collector is now incremental <whatsnew314-incremental-gc>`,
2836-
which means that the behavior of :func:`gc.collect` changes slightly:
2837-
2838-
* ``gc.collect(1)``: Performs an increment of garbage collection,
2839-
rather than collecting generation 1.
2840-
* Other calls to :func:`!gc.collect` are unchanged.
2841-
2842-
* The :func:`locale.nl_langinfo` function now temporarily sets the ``LC_CTYPE``
2843-
locale in some cases.
2844-
This temporary change affects other threads.
2845-
(Contributed by Serhiy Storchaka in :gh:`69998`.)
2846-
2847-
* :class:`types.UnionType` is now an alias for :class:`typing.Union`,
2848-
causing changes in some behaviors.
2849-
See :ref:`above <whatsnew314-typing-union>` for more details.
2850-
(Contributed by Jelle Zijlstra in :gh:`105499`.)
2851-
2852-
* The runtime behavior of annotations has changed in various ways; see
2853-
:ref:`above <whatsnew314-pep649>` for details. While most code that interacts
2854-
with annotations should continue to work, some undocumented details may behave
2855-
differently.
2856-
28572822

28582823
Build changes
28592824
=============
@@ -3048,63 +3013,6 @@ Limited C API changes
30483013
(Contributed by Victor Stinner in :gh:`91417`.)
30493014

30503015

3051-
Porting to Python 3.14
3052-
----------------------
3053-
3054-
* :c:func:`Py_Finalize` now deletes all interned strings. This
3055-
is backwards incompatible to any C-Extension that holds onto an interned
3056-
string after a call to :c:func:`Py_Finalize` and is then reused after a
3057-
call to :c:func:`Py_Initialize`. Any issues arising from this behavior will
3058-
normally result in crashes during the execution of the subsequent call to
3059-
:c:func:`Py_Initialize` from accessing uninitialized memory. To fix, use
3060-
an address sanitizer to identify any use-after-free coming from
3061-
an interned string and deallocate it during module shutdown.
3062-
(Contributed by Eddie Elizondo in :gh:`113601`.)
3063-
3064-
* The :ref:`Unicode Exception Objects <unicodeexceptions>` C API
3065-
now raises a :exc:`TypeError` if its exception argument is not
3066-
a :exc:`UnicodeError` object.
3067-
(Contributed by Bénédikt Tran in :gh:`127691`.)
3068-
3069-
.. _whatsnew314-refcount:
3070-
3071-
* The interpreter internally avoids some reference count modifications when
3072-
loading objects onto the operands stack by :term:`borrowing <borrowed reference>`
3073-
references when possible. This can lead to smaller reference count values
3074-
compared to previous Python versions. C API extensions that checked
3075-
:c:func:`Py_REFCNT` of ``1`` to determine if an function argument is not
3076-
referenced by any other code should instead use
3077-
:c:func:`PyUnstable_Object_IsUniqueReferencedTemporary` as a safer replacement.
3078-
3079-
3080-
* Private functions promoted to public C APIs:
3081-
3082-
* ``_PyBytes_Join()``: :c:func:`PyBytes_Join`
3083-
* ``_PyLong_IsNegative()``: :c:func:`PyLong_IsNegative`
3084-
* ``_PyLong_IsPositive()``: :c:func:`PyLong_IsPositive`
3085-
* ``_PyLong_IsZero()``: :c:func:`PyLong_IsZero`
3086-
* ``_PyLong_Sign()``: :c:func:`PyLong_GetSign`
3087-
* ``_PyUnicodeWriter_Dealloc()``: :c:func:`PyUnicodeWriter_Discard`
3088-
* ``_PyUnicodeWriter_Finish()``: :c:func:`PyUnicodeWriter_Finish`
3089-
* ``_PyUnicodeWriter_Init()``: use :c:func:`PyUnicodeWriter_Create`
3090-
* ``_PyUnicodeWriter_Prepare()``: (no replacement)
3091-
* ``_PyUnicodeWriter_PrepareKind()``: (no replacement)
3092-
* ``_PyUnicodeWriter_WriteChar()``: :c:func:`PyUnicodeWriter_WriteChar`
3093-
* ``_PyUnicodeWriter_WriteStr()``: :c:func:`PyUnicodeWriter_WriteStr`
3094-
* ``_PyUnicodeWriter_WriteSubstring()``: :c:func:`PyUnicodeWriter_WriteSubstring`
3095-
* ``_PyUnicode_EQ()``: :c:func:`PyUnicode_Equal`
3096-
* ``_PyUnicode_Equal()``: :c:func:`PyUnicode_Equal`
3097-
* ``_Py_GetConfig()``: :c:func:`PyConfig_Get` and :c:func:`PyConfig_GetInt`
3098-
* ``_Py_HashBytes()``: :c:func:`Py_HashBuffer`
3099-
* ``_Py_fopen_obj()``: :c:func:`Py_fopen`
3100-
* ``PyMutex_IsLocked()`` : :c:func:`PyMutex_IsLocked`
3101-
3102-
The `pythoncapi-compat project`_ can be used to get most of these new
3103-
functions on Python 3.13 and older.
3104-
3105-
.. _pythoncapi-compat project: https://github.com/python/pythoncapi-compat/
3106-
3107-
31083016
.. _whatsnew314-c-api-deprecated:
31093017

31103018
Deprecated
@@ -3210,3 +3118,97 @@ Removed
32103118
Please use :c:func:`Py_EnterRecursiveCall` to guard against runaway recursion
32113119
in C code.
32123120
(Removed in :gh:`133079`, see also :gh:`130396`.)
3121+
3122+
3123+
Porting to Python 3.14
3124+
======================
3125+
3126+
This section lists previously described changes and other bugfixes
3127+
that may require changes to your code.
3128+
3129+
3130+
Changes in the Python API
3131+
-------------------------
3132+
3133+
* :class:`functools.partial` is now a method descriptor.
3134+
Wrap it in :func:`staticmethod` if you want to preserve the old behavior.
3135+
(Contributed by Serhiy Storchaka and Dominykas Grigonis in :gh:`121027`.)
3136+
3137+
* The :ref:`garbage collector is now incremental <whatsnew314-incremental-gc>`,
3138+
which means that the behavior of :func:`gc.collect` changes slightly:
3139+
3140+
* ``gc.collect(1)``: Performs an increment of garbage collection,
3141+
rather than collecting generation 1.
3142+
* Other calls to :func:`!gc.collect` are unchanged.
3143+
3144+
* The :func:`locale.nl_langinfo` function now temporarily sets the ``LC_CTYPE``
3145+
locale in some cases.
3146+
This temporary change affects other threads.
3147+
(Contributed by Serhiy Storchaka in :gh:`69998`.)
3148+
3149+
* :class:`types.UnionType` is now an alias for :class:`typing.Union`,
3150+
causing changes in some behaviors.
3151+
See :ref:`above <whatsnew314-typing-union>` for more details.
3152+
(Contributed by Jelle Zijlstra in :gh:`105499`.)
3153+
3154+
* The runtime behavior of annotations has changed in various ways; see
3155+
:ref:`above <whatsnew314-pep649>` for details. While most code that interacts
3156+
with annotations should continue to work, some undocumented details may behave
3157+
differently.
3158+
3159+
3160+
Changes in the C API
3161+
--------------------
3162+
3163+
* :c:func:`Py_Finalize` now deletes all interned strings. This
3164+
is backwards incompatible to any C extension that holds onto an interned
3165+
string after a call to :c:func:`Py_Finalize` and is then reused after a
3166+
call to :c:func:`Py_Initialize`. Any issues arising from this behavior will
3167+
normally result in crashes during the execution of the subsequent call to
3168+
:c:func:`Py_Initialize` from accessing uninitialized memory. To fix, use
3169+
an address sanitizer to identify any use-after-free coming from
3170+
an interned string and deallocate it during module shutdown.
3171+
(Contributed by Eddie Elizondo in :gh:`113601`.)
3172+
3173+
* The :ref:`Unicode Exception Objects <unicodeexceptions>` C API
3174+
now raises a :exc:`TypeError` if its exception argument is not
3175+
a :exc:`UnicodeError` object.
3176+
(Contributed by Bénédikt Tran in :gh:`127691`.)
3177+
3178+
.. _whatsnew314-refcount:
3179+
3180+
* The interpreter internally avoids some reference count modifications when
3181+
loading objects onto the operands stack by :term:`borrowing <borrowed reference>`
3182+
references when possible. This can lead to smaller reference count values
3183+
compared to previous Python versions. C API extensions that checked
3184+
:c:func:`Py_REFCNT` of ``1`` to determine if an function argument is not
3185+
referenced by any other code should instead use
3186+
:c:func:`PyUnstable_Object_IsUniqueReferencedTemporary` as a safer replacement.
3187+
3188+
3189+
* Private functions promoted to public C APIs:
3190+
3191+
* ``_PyBytes_Join()``: :c:func:`PyBytes_Join`
3192+
* ``_PyLong_IsNegative()``: :c:func:`PyLong_IsNegative`
3193+
* ``_PyLong_IsPositive()``: :c:func:`PyLong_IsPositive`
3194+
* ``_PyLong_IsZero()``: :c:func:`PyLong_IsZero`
3195+
* ``_PyLong_Sign()``: :c:func:`PyLong_GetSign`
3196+
* ``_PyUnicodeWriter_Dealloc()``: :c:func:`PyUnicodeWriter_Discard`
3197+
* ``_PyUnicodeWriter_Finish()``: :c:func:`PyUnicodeWriter_Finish`
3198+
* ``_PyUnicodeWriter_Init()``: use :c:func:`PyUnicodeWriter_Create`
3199+
* ``_PyUnicodeWriter_Prepare()``: (no replacement)
3200+
* ``_PyUnicodeWriter_PrepareKind()``: (no replacement)
3201+
* ``_PyUnicodeWriter_WriteChar()``: :c:func:`PyUnicodeWriter_WriteChar`
3202+
* ``_PyUnicodeWriter_WriteStr()``: :c:func:`PyUnicodeWriter_WriteStr`
3203+
* ``_PyUnicodeWriter_WriteSubstring()``: :c:func:`PyUnicodeWriter_WriteSubstring`
3204+
* ``_PyUnicode_EQ()``: :c:func:`PyUnicode_Equal`
3205+
* ``_PyUnicode_Equal()``: :c:func:`PyUnicode_Equal`
3206+
* ``_Py_GetConfig()``: :c:func:`PyConfig_Get` and :c:func:`PyConfig_GetInt`
3207+
* ``_Py_HashBytes()``: :c:func:`Py_HashBuffer`
3208+
* ``_Py_fopen_obj()``: :c:func:`Py_fopen`
3209+
* ``PyMutex_IsLocked()`` : :c:func:`PyMutex_IsLocked`
3210+
3211+
The `pythoncapi-compat project`_ can be used to get most of these new
3212+
functions on Python 3.13 and older.
3213+
3214+
.. _pythoncapi-compat project: https://github.com/python/pythoncapi-compat/

Doc/whatsnew/3.15.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,15 @@ math
358358
(Contributed by Bénédikt Tran in :gh:`135853`.)
359359

360360

361+
mmap
362+
----
363+
364+
* :class:`mmap.mmap` now has a *trackfd* parameter on Windows;
365+
if it is ``False``, the file handle corresponding to *fileno* will
366+
not be duplicated.
367+
(Contributed by Serhiy Storchaka in :gh:`78502`.)
368+
369+
361370
os.path
362371
-------
363372

0 commit comments

Comments
 (0)