Skip to content

Commit 1fa0e35

Browse files
authored
Merge branch 'main' into gh-145678-grouper-uaf
2 parents 39dd69c + 453562a commit 1fa0e35

File tree

306 files changed

+5891
-3481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

306 files changed

+5891
-3481
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ Tools/c-analyzer/ @ericsnowcurrently
132132
Tools/check-c-api-docs/ @ZeroIntensity
133133

134134
# Fuzzing
135-
Modules/_xxtestfuzz/ @ammaraskar
135+
Modules/_xxtestfuzz/ @python/fuzzers
136+
Lib/test/test_xxtestfuzz.py @python/fuzzers
137+
.github/workflows/reusable-cifuzz.yml @python/fuzzers
136138

137139
# Limited C API & Stable ABI
138140
Doc/c-api/stable.rst @encukou

Doc/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ htmlhelp: build
8888
"build/htmlhelp/pydoc.hhp project file."
8989

9090
.PHONY: latex
91+
latex: _ensure-sphinxcontrib-svg2pdfconverter
9192
latex: BUILDER = latex
9293
latex: build
9394
@echo "Build finished; the LaTeX files are in build/latex."
@@ -231,7 +232,7 @@ dist-text:
231232
@echo "Build finished and archived!"
232233

233234
.PHONY: dist-pdf
234-
dist-pdf:
235+
dist-pdf: _ensure-sphinxcontrib-svg2pdfconverter
235236
# archive the A4 latex
236237
@echo "Building LaTeX (A4 paper)..."
237238
mkdir -p dist
@@ -292,6 +293,10 @@ _ensure-pre-commit:
292293
_ensure-sphinx-autobuild:
293294
$(MAKE) _ensure-package PACKAGE=sphinx-autobuild
294295

296+
.PHONY: _ensure-sphinxcontrib-svg2pdfconverter
297+
_ensure-sphinxcontrib-svg2pdfconverter:
298+
$(MAKE) _ensure-package PACKAGE=sphinxcontrib-svg2pdfconverter
299+
295300
.PHONY: check
296301
check: _ensure-pre-commit
297302
$(VENVDIR)/bin/python3 -m pre_commit run --all-files

Doc/c-api/arg.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ API Functions
524524
Returns true on success; on failure, it returns false and raises the
525525
appropriate exception.
526526
527-
.. versionadded:: next
527+
.. versionadded:: 3.15
528528
529529
530530
.. c:function:: int PyArg_ParseArrayAndKeywords(PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames, const char *format, const char * const *kwlist, ...)
@@ -535,7 +535,7 @@ API Functions
535535
Returns true on success; on failure, it returns false and raises the
536536
appropriate exception.
537537
538-
.. versionadded:: next
538+
.. versionadded:: 3.15
539539
540540
541541
.. c:function:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...)

Doc/c-api/dict.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ Dictionary view objects
495495
Frozen dictionary objects
496496
^^^^^^^^^^^^^^^^^^^^^^^^^
497497
498-
.. versionadded:: next
498+
.. versionadded:: 3.15
499499
500500
501501
.. c:var:: PyTypeObject PyFrozenDict_Type

Doc/c-api/exceptions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ Signal Handling
716716
This function may now execute a remote debugger script, if remote
717717
debugging is enabled.
718718
719-
.. versionchanged:: next
719+
.. versionchanged:: 3.15
720720
The exception set by :c:func:`PyThreadState_SetAsyncExc` is now raised.
721721
722722

Doc/c-api/float.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,6 @@ endian processor, or ``0`` on little endian processor.
224224
Return value: ``0`` if all is OK, ``-1`` if error (and an exception is set,
225225
most likely :exc:`OverflowError`).
226226
227-
There are two problems on non-IEEE platforms:
228-
229-
* What this does is undefined if *x* is a NaN or infinity.
230-
* ``-0.0`` and ``+0.0`` produce the same bytes string.
231-
232227
.. c:function:: int PyFloat_Pack2(double x, char *p, int le)
233228
234229
Pack a C double as the IEEE 754 binary16 half-precision format.
@@ -256,9 +251,6 @@ Return value: The unpacked double. On error, this is ``-1.0`` and
256251
:c:func:`PyErr_Occurred` is true (and an exception is set, most likely
257252
:exc:`OverflowError`).
258253
259-
Note that on a non-IEEE platform this will refuse to unpack a bytes string that
260-
represents a NaN or infinity.
261-
262254
.. c:function:: double PyFloat_Unpack2(const char *p, int le)
263255
264256
Unpack the IEEE 754 binary16 half-precision format as a C double.

Doc/c-api/import.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,14 @@ Importing Modules
350350
351351
Gets the current lazy imports mode.
352352
353-
.. versionadded:: next
353+
.. versionadded:: 3.15
354354
355355
.. c:function:: PyObject* PyImport_GetLazyImportsFilter()
356356
357357
Return a :term:`strong reference` to the current lazy imports filter,
358358
or ``NULL`` if none exists. This function always succeeds.
359359
360-
.. versionadded:: next
360+
.. versionadded:: 3.15
361361
362362
.. c:function:: int PyImport_SetLazyImportsMode(PyImport_LazyImportsMode mode)
363363
@@ -366,7 +366,7 @@ Importing Modules
366366
367367
This function always returns ``0``.
368368
369-
.. versionadded:: next
369+
.. versionadded:: 3.15
370370
371371
.. c:function:: int PyImport_SetLazyImportsFilter(PyObject *filter)
372372
@@ -377,7 +377,7 @@ Importing Modules
377377
378378
Return ``0`` on success and ``-1`` with an exception set otherwise.
379379
380-
.. versionadded:: next
380+
.. versionadded:: 3.15
381381
382382
.. c:type:: PyImport_LazyImportsMode
383383
@@ -396,7 +396,7 @@ Importing Modules
396396
Disable lazy imports entirely. Even explicit ``lazy`` statements become
397397
eager imports.
398398
399-
.. versionadded:: next
399+
.. versionadded:: 3.15
400400
401401
.. c:function:: PyObject* PyImport_CreateModuleFromInitfunc(PyObject *spec, PyObject* (*initfunc)(void))
402402

Doc/c-api/memory.rst

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ The following function sets, modeled after the ANSI C standard, but specifying
204204
behavior when requesting zero bytes, are available for allocating and releasing
205205
memory from the Python heap.
206206
207-
The :ref:`default memory allocator <default-memory-allocators>` uses the
208-
:ref:`pymalloc memory allocator <pymalloc>`.
207+
In the GIL-enabled build (default build) the
208+
:ref:`default memory allocator <default-memory-allocators>` uses the
209+
:ref:`pymalloc memory allocator <pymalloc>`, whereas in the
210+
:term:`free-threaded build`, the default is the
211+
:ref:`mimalloc memory allocator <mimalloc>` instead.
209212
210213
.. warning::
211214
@@ -215,6 +218,11 @@ The :ref:`default memory allocator <default-memory-allocators>` uses the
215218
216219
The default allocator is now pymalloc instead of system :c:func:`malloc`.
217220
221+
.. versionchanged:: 3.13
222+
223+
In the :term:`free-threaded <free threading>` build, the default allocator
224+
is now :ref:`mimalloc <mimalloc>`.
225+
218226
.. c:function:: void* PyMem_Malloc(size_t n)
219227
220228
Allocates *n* bytes and returns a pointer of type :c:expr:`void*` to the
@@ -340,7 +348,9 @@ memory from the Python heap.
340348
the :ref:`Customize Memory Allocators <customize-memory-allocators>` section.
341349
342350
The :ref:`default object allocator <default-memory-allocators>` uses the
343-
:ref:`pymalloc memory allocator <pymalloc>`.
351+
:ref:`pymalloc memory allocator <pymalloc>`. In the
352+
:term:`free-threaded <free threading>` build, the default is the
353+
:ref:`mimalloc memory allocator <mimalloc>` instead.
344354
345355
.. warning::
346356
@@ -420,23 +430,24 @@ Default Memory Allocators
420430
421431
Default memory allocators:
422432
423-
=============================== ==================== ================== ===================== ====================
424-
Configuration Name PyMem_RawMalloc PyMem_Malloc PyObject_Malloc
425-
=============================== ==================== ================== ===================== ====================
426-
Release build ``"pymalloc"`` ``malloc`` ``pymalloc`` ``pymalloc``
427-
Debug build ``"pymalloc_debug"`` ``malloc`` + debug ``pymalloc`` + debug ``pymalloc`` + debug
428-
Release build, without pymalloc ``"malloc"`` ``malloc`` ``malloc`` ``malloc``
429-
Debug build, without pymalloc ``"malloc_debug"`` ``malloc`` + debug ``malloc`` + debug ``malloc`` + debug
430-
=============================== ==================== ================== ===================== ====================
433+
=================================== ======================= ==================== ====================== ======================
434+
Configuration Name PyMem_RawMalloc PyMem_Malloc PyObject_Malloc
435+
=================================== ======================= ==================== ====================== ======================
436+
Release build ``"pymalloc"`` ``malloc`` ``pymalloc`` ``pymalloc``
437+
Debug build ``"pymalloc_debug"`` ``malloc`` + debug ``pymalloc`` + debug ``pymalloc`` + debug
438+
Release build, without pymalloc ``"malloc"`` ``malloc`` ``malloc`` ``malloc``
439+
Debug build, without pymalloc ``"malloc_debug"`` ``malloc`` + debug ``malloc`` + debug ``malloc`` + debug
440+
Free-threaded build ``"mimalloc"`` ``mimalloc`` ``mimalloc`` ``mimalloc``
441+
Free-threaded debug build ``"mimalloc_debug"`` ``mimalloc`` + debug ``mimalloc`` + debug ``mimalloc`` + debug
442+
=================================== ======================= ==================== ====================== ======================
431443
432444
Legend:
433445
434446
* Name: value for :envvar:`PYTHONMALLOC` environment variable.
435447
* ``malloc``: system allocators from the standard C library, C functions:
436448
:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`.
437449
* ``pymalloc``: :ref:`pymalloc memory allocator <pymalloc>`.
438-
* ``mimalloc``: :ref:`mimalloc memory allocator <mimalloc>`. The pymalloc
439-
allocator will be used if mimalloc support isn't available.
450+
* ``mimalloc``: :ref:`mimalloc memory allocator <mimalloc>`.
440451
* "+ debug": with :ref:`debug hooks on the Python memory allocators
441452
<pymem-debug-hooks>`.
442453
* "Debug build": :ref:`Python build in debug mode <debug-build>`.
@@ -733,9 +744,27 @@ The mimalloc allocator
733744
734745
.. versionadded:: 3.13
735746
736-
Python supports the mimalloc allocator when the underlying platform support is available.
737-
mimalloc "is a general purpose allocator with excellent performance characteristics.
738-
Initially developed by Daan Leijen for the runtime systems of the Koka and Lean languages."
747+
Python supports the `mimalloc <https://github.com/microsoft/mimalloc/>`__
748+
allocator when the underlying platform support is available.
749+
mimalloc is a general purpose allocator with excellent performance
750+
characteristics, initially developed by Daan Leijen for the runtime systems
751+
of the Koka and Lean languages.
752+
753+
Unlike :ref:`pymalloc <pymalloc>`, which is optimized for small objects (512
754+
bytes or fewer), mimalloc handles allocations of any size.
755+
756+
In the :term:`free-threaded <free threading>` build, mimalloc is the default
757+
and **required** allocator for the :c:macro:`PYMEM_DOMAIN_MEM` and
758+
:c:macro:`PYMEM_DOMAIN_OBJ` domains. It cannot be disabled in free-threaded
759+
builds. The free-threaded build uses per-thread mimalloc heaps, which allows
760+
allocation and deallocation to proceed without locking in most cases.
761+
762+
In the default (non-free-threaded) build, mimalloc is available but not the
763+
default allocator. It can be selected at runtime using
764+
:envvar:`PYTHONMALLOC`\ ``=mimalloc`` (or ``mimalloc_debug`` to include
765+
:ref:`debug hooks <pymem-debug-hooks>`). It can be disabled at build time
766+
using the :option:`--without-mimalloc` configure option, but this option
767+
cannot be combined with :option:`--disable-gil`.
739768
740769
tracemalloc C API
741770
=================

Doc/c-api/object.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,4 +817,4 @@ Object Protocol
817817
Returns 1 if the object was made immortal and returns 0 if it was not.
818818
This function cannot fail.
819819
820-
.. versionadded:: next
820+
.. versionadded:: 3.15

Doc/c-api/structures.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ under :ref:`reference counting <countingrefs>`.
4848
Do not use this field directly; use :c:macro:`Py_TYPE` and
4949
:c:func:`Py_SET_TYPE` instead.
5050

51+
.. c:member:: PyMutex ob_mutex
52+
53+
A :ref:`per-object lock <per-object-locks>`, present only in the :term:`free-threaded <free threading>`
54+
build (when :c:macro:`Py_GIL_DISABLED` is defined).
55+
56+
This field is **reserved for use by the critical section API**
57+
(:c:macro:`Py_BEGIN_CRITICAL_SECTION` / :c:macro:`Py_END_CRITICAL_SECTION`).
58+
Do **not** lock it directly with ``PyMutex_Lock``; doing so can cause
59+
deadlocks. If you need your own lock, add a separate :c:type:`PyMutex`
60+
field to your object struct.
61+
62+
.. versionadded:: 3.13
63+
5164

5265
.. c:type:: PyVarObject
5366

0 commit comments

Comments
 (0)