Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Doc/howto/instrumentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ should instead read:
(assuming a :ref:`debug build <debug-build>` of CPython 3.6)


.. _static-markers:

Available static markers
------------------------

Expand Down
6 changes: 4 additions & 2 deletions Doc/library/curses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,10 @@ The module :mod:`curses` defines the following functions:
Window Objects
--------------

Window objects, as returned by :func:`initscr` and :func:`newwin` above, have
the following methods and attributes:
.. class:: window

Window objects, as returned by :func:`initscr` and :func:`newwin` above, have
the following methods and attributes:


.. method:: window.addch(ch[, attr])
Expand Down
4 changes: 3 additions & 1 deletion Doc/library/hmac.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ cannot be used with HMAC.
.. versionadded:: 3.7


An HMAC object has the following methods:
.. class:: HMAC

An HMAC object has the following methods:

.. method:: HMAC.update(msg)

Expand Down
16 changes: 14 additions & 2 deletions Doc/library/mmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ update the underlying file.

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

.. class:: mmap(fileno, length, tagname=None, access=ACCESS_DEFAULT, offset=0)
.. class:: mmap(fileno, length, tagname=None, \
access=ACCESS_DEFAULT, offset=0, *, trackfd=True)

**(Windows version)** Maps *length* bytes from the file specified by the
file handle *fileno*, and creates a mmap object. If *length* is larger
file descriptor *fileno*, and creates a mmap object. If *length* is larger
than the current size of the file, the file is extended to contain *length*
bytes. If *length* is ``0``, the maximum length of the map is the current
size of the file, except that if the file is empty Windows raises an
Expand All @@ -69,6 +70,17 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
will be relative to the offset from the beginning of the file. *offset*
defaults to 0. *offset* must be a multiple of the :const:`ALLOCATIONGRANULARITY`.

If *trackfd* is ``False``, the file handle corresponding to *fileno* will
not be duplicated, and the resulting :class:`!mmap` object will not
be associated with the map's underlying file.
This means that the :meth:`~mmap.mmap.size` and :meth:`~mmap.mmap.resize`
methods will fail.
This mode is useful to limit the number of open file handles.
The original file can be renamed (but not deleted) after closing *fileno*.

.. versionchanged:: next
The *trackfd* parameter was added.

.. audit-event:: mmap.__new__ fileno,length,access,offset mmap.mmap

.. class:: mmap(fileno, length, flags=MAP_SHARED, prot=PROT_WRITE|PROT_READ, \
Expand Down
4 changes: 4 additions & 0 deletions Doc/library/unittest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2532,6 +2532,10 @@ instead of as an error.
setUpModule and tearDownModule
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. function:: setUpModule
tearDownModule
:no-typesetting:

These should be implemented as functions::

def setUpModule():
Expand Down
5 changes: 5 additions & 0 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2351,6 +2351,9 @@ Customizing module attribute access
single: __dir__ (module attribute)
single: __class__ (module attribute)

.. method:: module.__getattr__
module.__dir__

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

.. attribute:: module.__class__

For a more fine grained customization of the module behavior (setting
attributes, properties, etc.), one can set the ``__class__`` attribute of
a module object to a subclass of :class:`types.ModuleType`. For example::
Expand Down
3 changes: 0 additions & 3 deletions Doc/tools/.nitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ Doc/whatsnew/2.4.rst
Doc/whatsnew/2.5.rst
Doc/whatsnew/2.6.rst
Doc/whatsnew/2.7.rst
Doc/whatsnew/3.3.rst
Doc/whatsnew/3.4.rst
Doc/whatsnew/3.5.rst
Doc/whatsnew/3.6.rst
Doc/whatsnew/3.7.rst
Doc/whatsnew/3.8.rst
Doc/whatsnew/3.10.rst
186 changes: 94 additions & 92 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2819,41 +2819,6 @@ CPython bytecode changes
* Replaced the opcode ``BINARY_SUBSCR`` by :opcode:`BINARY_OP` with oparg ``NB_SUBSCR``.
(Contributed by Irit Katriel in :gh:`100239`.)

Porting to Python 3.14
======================

This section lists previously described changes and other bugfixes
that may require changes to your code.

Changes in the Python API
-------------------------

* :class:`functools.partial` is now a method descriptor.
Wrap it in :func:`staticmethod` if you want to preserve the old behavior.
(Contributed by Serhiy Storchaka and Dominykas Grigonis in :gh:`121027`.)

* The :ref:`garbage collector is now incremental <whatsnew314-incremental-gc>`,
which means that the behavior of :func:`gc.collect` changes slightly:

* ``gc.collect(1)``: Performs an increment of garbage collection,
rather than collecting generation 1.
* Other calls to :func:`!gc.collect` are unchanged.

* The :func:`locale.nl_langinfo` function now temporarily sets the ``LC_CTYPE``
locale in some cases.
This temporary change affects other threads.
(Contributed by Serhiy Storchaka in :gh:`69998`.)

* :class:`types.UnionType` is now an alias for :class:`typing.Union`,
causing changes in some behaviors.
See :ref:`above <whatsnew314-typing-union>` for more details.
(Contributed by Jelle Zijlstra in :gh:`105499`.)

* The runtime behavior of annotations has changed in various ways; see
:ref:`above <whatsnew314-pep649>` for details. While most code that interacts
with annotations should continue to work, some undocumented details may behave
differently.


Build changes
=============
Expand Down Expand Up @@ -3048,63 +3013,6 @@ Limited C API changes
(Contributed by Victor Stinner in :gh:`91417`.)


Porting to Python 3.14
----------------------

* :c:func:`Py_Finalize` now deletes all interned strings. This
is backwards incompatible to any C-Extension that holds onto an interned
string after a call to :c:func:`Py_Finalize` and is then reused after a
call to :c:func:`Py_Initialize`. Any issues arising from this behavior will
normally result in crashes during the execution of the subsequent call to
:c:func:`Py_Initialize` from accessing uninitialized memory. To fix, use
an address sanitizer to identify any use-after-free coming from
an interned string and deallocate it during module shutdown.
(Contributed by Eddie Elizondo in :gh:`113601`.)

* The :ref:`Unicode Exception Objects <unicodeexceptions>` C API
now raises a :exc:`TypeError` if its exception argument is not
a :exc:`UnicodeError` object.
(Contributed by Bénédikt Tran in :gh:`127691`.)

.. _whatsnew314-refcount:

* The interpreter internally avoids some reference count modifications when
loading objects onto the operands stack by :term:`borrowing <borrowed reference>`
references when possible. This can lead to smaller reference count values
compared to previous Python versions. C API extensions that checked
:c:func:`Py_REFCNT` of ``1`` to determine if an function argument is not
referenced by any other code should instead use
:c:func:`PyUnstable_Object_IsUniqueReferencedTemporary` as a safer replacement.


* Private functions promoted to public C APIs:

* ``_PyBytes_Join()``: :c:func:`PyBytes_Join`
* ``_PyLong_IsNegative()``: :c:func:`PyLong_IsNegative`
* ``_PyLong_IsPositive()``: :c:func:`PyLong_IsPositive`
* ``_PyLong_IsZero()``: :c:func:`PyLong_IsZero`
* ``_PyLong_Sign()``: :c:func:`PyLong_GetSign`
* ``_PyUnicodeWriter_Dealloc()``: :c:func:`PyUnicodeWriter_Discard`
* ``_PyUnicodeWriter_Finish()``: :c:func:`PyUnicodeWriter_Finish`
* ``_PyUnicodeWriter_Init()``: use :c:func:`PyUnicodeWriter_Create`
* ``_PyUnicodeWriter_Prepare()``: (no replacement)
* ``_PyUnicodeWriter_PrepareKind()``: (no replacement)
* ``_PyUnicodeWriter_WriteChar()``: :c:func:`PyUnicodeWriter_WriteChar`
* ``_PyUnicodeWriter_WriteStr()``: :c:func:`PyUnicodeWriter_WriteStr`
* ``_PyUnicodeWriter_WriteSubstring()``: :c:func:`PyUnicodeWriter_WriteSubstring`
* ``_PyUnicode_EQ()``: :c:func:`PyUnicode_Equal`
* ``_PyUnicode_Equal()``: :c:func:`PyUnicode_Equal`
* ``_Py_GetConfig()``: :c:func:`PyConfig_Get` and :c:func:`PyConfig_GetInt`
* ``_Py_HashBytes()``: :c:func:`Py_HashBuffer`
* ``_Py_fopen_obj()``: :c:func:`Py_fopen`
* ``PyMutex_IsLocked()`` : :c:func:`PyMutex_IsLocked`

The `pythoncapi-compat project`_ can be used to get most of these new
functions on Python 3.13 and older.

.. _pythoncapi-compat project: https://github.com/python/pythoncapi-compat/


.. _whatsnew314-c-api-deprecated:

Deprecated
Expand Down Expand Up @@ -3210,3 +3118,97 @@ Removed
Please use :c:func:`Py_EnterRecursiveCall` to guard against runaway recursion
in C code.
(Removed in :gh:`133079`, see also :gh:`130396`.)


Porting to Python 3.14
======================

This section lists previously described changes and other bugfixes
that may require changes to your code.


Changes in the Python API
-------------------------

* :class:`functools.partial` is now a method descriptor.
Wrap it in :func:`staticmethod` if you want to preserve the old behavior.
(Contributed by Serhiy Storchaka and Dominykas Grigonis in :gh:`121027`.)

* The :ref:`garbage collector is now incremental <whatsnew314-incremental-gc>`,
which means that the behavior of :func:`gc.collect` changes slightly:

* ``gc.collect(1)``: Performs an increment of garbage collection,
rather than collecting generation 1.
* Other calls to :func:`!gc.collect` are unchanged.

* The :func:`locale.nl_langinfo` function now temporarily sets the ``LC_CTYPE``
locale in some cases.
This temporary change affects other threads.
(Contributed by Serhiy Storchaka in :gh:`69998`.)

* :class:`types.UnionType` is now an alias for :class:`typing.Union`,
causing changes in some behaviors.
See :ref:`above <whatsnew314-typing-union>` for more details.
(Contributed by Jelle Zijlstra in :gh:`105499`.)

* The runtime behavior of annotations has changed in various ways; see
:ref:`above <whatsnew314-pep649>` for details. While most code that interacts
with annotations should continue to work, some undocumented details may behave
differently.


Changes in the C API
--------------------

* :c:func:`Py_Finalize` now deletes all interned strings. This
is backwards incompatible to any C extension that holds onto an interned
string after a call to :c:func:`Py_Finalize` and is then reused after a
call to :c:func:`Py_Initialize`. Any issues arising from this behavior will
normally result in crashes during the execution of the subsequent call to
:c:func:`Py_Initialize` from accessing uninitialized memory. To fix, use
an address sanitizer to identify any use-after-free coming from
an interned string and deallocate it during module shutdown.
(Contributed by Eddie Elizondo in :gh:`113601`.)

* The :ref:`Unicode Exception Objects <unicodeexceptions>` C API
now raises a :exc:`TypeError` if its exception argument is not
a :exc:`UnicodeError` object.
(Contributed by Bénédikt Tran in :gh:`127691`.)

.. _whatsnew314-refcount:

* The interpreter internally avoids some reference count modifications when
loading objects onto the operands stack by :term:`borrowing <borrowed reference>`
references when possible. This can lead to smaller reference count values
compared to previous Python versions. C API extensions that checked
:c:func:`Py_REFCNT` of ``1`` to determine if an function argument is not
referenced by any other code should instead use
:c:func:`PyUnstable_Object_IsUniqueReferencedTemporary` as a safer replacement.


* Private functions promoted to public C APIs:

* ``_PyBytes_Join()``: :c:func:`PyBytes_Join`
* ``_PyLong_IsNegative()``: :c:func:`PyLong_IsNegative`
* ``_PyLong_IsPositive()``: :c:func:`PyLong_IsPositive`
* ``_PyLong_IsZero()``: :c:func:`PyLong_IsZero`
* ``_PyLong_Sign()``: :c:func:`PyLong_GetSign`
* ``_PyUnicodeWriter_Dealloc()``: :c:func:`PyUnicodeWriter_Discard`
* ``_PyUnicodeWriter_Finish()``: :c:func:`PyUnicodeWriter_Finish`
* ``_PyUnicodeWriter_Init()``: use :c:func:`PyUnicodeWriter_Create`
* ``_PyUnicodeWriter_Prepare()``: (no replacement)
* ``_PyUnicodeWriter_PrepareKind()``: (no replacement)
* ``_PyUnicodeWriter_WriteChar()``: :c:func:`PyUnicodeWriter_WriteChar`
* ``_PyUnicodeWriter_WriteStr()``: :c:func:`PyUnicodeWriter_WriteStr`
* ``_PyUnicodeWriter_WriteSubstring()``: :c:func:`PyUnicodeWriter_WriteSubstring`
* ``_PyUnicode_EQ()``: :c:func:`PyUnicode_Equal`
* ``_PyUnicode_Equal()``: :c:func:`PyUnicode_Equal`
* ``_Py_GetConfig()``: :c:func:`PyConfig_Get` and :c:func:`PyConfig_GetInt`
* ``_Py_HashBytes()``: :c:func:`Py_HashBuffer`
* ``_Py_fopen_obj()``: :c:func:`Py_fopen`
* ``PyMutex_IsLocked()`` : :c:func:`PyMutex_IsLocked`

The `pythoncapi-compat project`_ can be used to get most of these new
functions on Python 3.13 and older.

.. _pythoncapi-compat project: https://github.com/python/pythoncapi-compat/
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,15 @@ math
(Contributed by Bénédikt Tran in :gh:`135853`.)


mmap
----

* :class:`mmap.mmap` now has a *trackfd* parameter on Windows;
if it is ``False``, the file handle corresponding to *fileno* will
not be duplicated.
(Contributed by Serhiy Storchaka in :gh:`78502`.)


os.path
-------

Expand Down
Loading
Loading