Skip to content

Commit 37d3446

Browse files
committed
Deploying to gh-pages from @ 5c9e7b5 🚀
1 parent 15bd46b commit 37d3446

File tree

643 files changed

+12566
-10560
lines changed

Some content is hidden

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

643 files changed

+12566
-10560
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: d6751eade72bed0b8f7a3e9e8373c012
3+
config: 429e5f11a7c447b979c1ef472ceffa09
44
tags: b5e2c454ba7771976391ed0cecdde553

_sources/c-api/bytearray.rst.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ Direct API functions
4444
4545
On failure, return ``NULL`` with an exception set.
4646
47+
.. note::
48+
If the object implements the buffer protocol, then the buffer
49+
must not be mutated while the bytearray object is being created.
50+
4751
4852
.. c:function:: PyObject* PyByteArray_FromStringAndSize(const char *string, Py_ssize_t len)
4953
@@ -58,6 +62,10 @@ Direct API functions
5862
5963
On failure, return ``NULL`` with an exception set.
6064
65+
.. note::
66+
If the object implements the buffer protocol, then the buffer
67+
must not be mutated while the bytearray object is being created.
68+
6169
6270
.. c:function:: Py_ssize_t PyByteArray_Size(PyObject *bytearray)
6371
@@ -70,6 +78,9 @@ Direct API functions
7078
``NULL`` pointer. The returned array always has an extra
7179
null byte appended.
7280
81+
.. note::
82+
It is not thread-safe to mutate the bytearray object while using the returned char array.
83+
7384
7485
.. c:function:: int PyByteArray_Resize(PyObject *bytearray, Py_ssize_t len)
7586
@@ -89,6 +100,9 @@ These macros trade safety for speed and they don't check pointers.
89100
90101
Similar to :c:func:`PyByteArray_AsString`, but without error checking.
91102
103+
.. note::
104+
It is not thread-safe to mutate the bytearray object while using the returned char array.
105+
92106
93107
.. c:function:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
94108

_sources/c-api/bytes.rst.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ called with a non-bytes parameter.
123123
Return the bytes representation of object *o* that implements the buffer
124124
protocol.
125125
126+
.. note::
127+
If the object implements the buffer protocol, then the buffer
128+
must not be mutated while the bytes object is being created.
129+
126130
127131
.. c:function:: Py_ssize_t PyBytes_Size(PyObject *o)
128132
@@ -181,13 +185,20 @@ called with a non-bytes parameter.
181185
created, the old reference to *bytes* will still be discarded and the value
182186
of *\*bytes* will be set to ``NULL``; the appropriate exception will be set.
183187
188+
.. note::
189+
If *newpart* implements the buffer protocol, then the buffer
190+
must not be mutated while the new bytes object is being created.
184191
185192
.. c:function:: void PyBytes_ConcatAndDel(PyObject **bytes, PyObject *newpart)
186193
187194
Create a new bytes object in *\*bytes* containing the contents of *newpart*
188195
appended to *bytes*. This version releases the :term:`strong reference`
189196
to *newpart* (i.e. decrements its reference count).
190197
198+
.. note::
199+
If *newpart* implements the buffer protocol, then the buffer
200+
must not be mutated while the new bytes object is being created.
201+
191202
192203
.. c:function:: PyObject* PyBytes_Join(PyObject *sep, PyObject *iterable)
193204
@@ -206,6 +217,9 @@ called with a non-bytes parameter.
206217
207218
.. versionadded:: 3.14
208219
220+
.. note::
221+
If *iterable* objects implement the buffer protocol, then the buffers
222+
must not be mutated while the new bytes object is being created.
209223
210224
.. c:function:: int _PyBytes_Resize(PyObject **bytes, Py_ssize_t newsize)
211225

_sources/c-api/file.rst.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,12 @@ the :mod:`io` APIs instead.
123123
124124
Write object *obj* to file object *p*. The only supported flag for *flags* is
125125
:c:macro:`Py_PRINT_RAW`; if given, the :func:`str` of the object is written
126-
instead of the :func:`repr`. Return ``0`` on success or ``-1`` on failure; the
127-
appropriate exception will be set.
126+
instead of the :func:`repr`.
127+
128+
If *obj* is ``NULL``, write the string ``"<NULL>"``.
128129
130+
Return ``0`` on success or ``-1`` on failure; the
131+
appropriate exception will be set.
129132
130133
.. c:function:: int PyFile_WriteString(const char *s, PyObject *p)
131134

_sources/c-api/float.rst.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ NaNs (if such things exist on the platform) isn't handled correctly, and
194194
attempting to unpack a bytes string containing an IEEE INF or NaN will raise an
195195
exception.
196196
197-
Note that NaNs type may not be preserved on IEEE platforms (signaling NaN become
198-
quiet NaN), for example on x86 systems in 32-bit mode.
197+
Note that NaN type may not be preserved on IEEE platforms (signaling NaNs become
198+
quiet NaNs), for example on x86 systems in 32-bit mode.
199199
200200
On non-IEEE platforms with more precision, or larger dynamic range, than IEEE
201201
754 supports, not all values can be packed; on non-IEEE platforms with less
@@ -209,7 +209,7 @@ Pack functions
209209
210210
The pack routines write 2, 4 or 8 bytes, starting at *p*. *le* is an
211211
:c:expr:`int` argument, non-zero if you want the bytes string in little-endian
212-
format (exponent last, at ``p+1``, ``p+3``, or ``p+6`` ``p+7``), zero if you
212+
format (exponent last, at ``p+1``, ``p+3``, or ``p+6`` and ``p+7``), zero if you
213213
want big-endian format (exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN`
214214
constant can be used to use the native endian: it is equal to ``1`` on big
215215
endian processor, or ``0`` on little endian processor.

_sources/c-api/list.rst.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,25 @@ List Objects
7474
Like :c:func:`PyList_GetItemRef`, but returns a
7575
:term:`borrowed reference` instead of a :term:`strong reference`.
7676
77+
.. note::
78+
79+
In the :term:`free-threaded build`, the returned
80+
:term:`borrowed reference` may become invalid if another thread modifies
81+
the list concurrently. Prefer :c:func:`PyList_GetItemRef`, which returns
82+
a :term:`strong reference`.
83+
7784
7885
.. c:function:: PyObject* PyList_GET_ITEM(PyObject *list, Py_ssize_t i)
7986
8087
Similar to :c:func:`PyList_GetItem`, but without error checking.
8188
89+
.. note::
90+
91+
In the :term:`free-threaded build`, the returned
92+
:term:`borrowed reference` may become invalid if another thread modifies
93+
the list concurrently. Prefer :c:func:`PyList_GetItemRef`, which returns
94+
a :term:`strong reference`.
95+
8296
8397
.. c:function:: int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item)
8498
@@ -108,6 +122,14 @@ List Objects
108122
is being replaced; any reference in *list* at position *i* will be
109123
leaked.
110124
125+
.. note::
126+
127+
In the :term:`free-threaded build`, this macro has no internal
128+
synchronization. It is normally only used to fill in new lists where no
129+
other thread has a reference to the list. If the list may be shared,
130+
use :c:func:`PyList_SetItem` instead, which uses a :term:`per-object
131+
lock`.
132+
111133
112134
.. c:function:: int PyList_Insert(PyObject *list, Py_ssize_t index, PyObject *item)
113135
@@ -138,6 +160,12 @@ List Objects
138160
Return ``0`` on success, ``-1`` on failure. Indexing from the end of the
139161
list is not supported.
140162
163+
.. note::
164+
165+
In the :term:`free-threaded build`, when *itemlist* is a :class:`list`,
166+
both *list* and *itemlist* are locked for the duration of the operation.
167+
For other iterables (or ``NULL``), only *list* is locked.
168+
141169
142170
.. c:function:: int PyList_Extend(PyObject *list, PyObject *iterable)
143171
@@ -150,6 +178,14 @@ List Objects
150178
151179
.. versionadded:: 3.13
152180
181+
.. note::
182+
183+
In the :term:`free-threaded build`, when *iterable* is a :class:`list`,
184+
:class:`set`, :class:`dict`, or dict view, both *list* and *iterable*
185+
(or its underlying dict) are locked for the duration of the operation.
186+
For other iterables, only *list* is locked; *iterable* may be
187+
concurrently modified by another thread.
188+
153189
154190
.. c:function:: int PyList_Clear(PyObject *list)
155191
@@ -168,6 +204,14 @@ List Objects
168204
Sort the items of *list* in place. Return ``0`` on success, ``-1`` on
169205
failure. This is equivalent to ``list.sort()``.
170206
207+
.. note::
208+
209+
In the :term:`free-threaded build`, element comparison via
210+
:meth:`~object.__lt__` can execute arbitrary Python code, during which
211+
the :term:`per-object lock` may be temporarily released. For built-in
212+
types (:class:`str`, :class:`int`, :class:`float`), the lock is not
213+
released during comparison.
214+
171215
172216
.. c:function:: int PyList_Reverse(PyObject *list)
173217

_sources/c-api/object.rst.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ Object Protocol
319319
representation on success, ``NULL`` on failure. This is the equivalent of the
320320
Python expression ``repr(o)``. Called by the :func:`repr` built-in function.
321321
322+
If argument is ``NULL``, return the string ``'<NULL>'``.
323+
322324
.. versionchanged:: 3.4
323325
This function now includes a debug assertion to help ensure that it
324326
does not silently discard an active exception.
@@ -333,6 +335,8 @@ Object Protocol
333335
a string similar to that returned by :c:func:`PyObject_Repr` in Python 2.
334336
Called by the :func:`ascii` built-in function.
335337
338+
If argument is ``NULL``, return the string ``'<NULL>'``.
339+
336340
.. index:: string; PyObject_Str (C function)
337341
338342
@@ -343,6 +347,8 @@ Object Protocol
343347
Python expression ``str(o)``. Called by the :func:`str` built-in function
344348
and, therefore, by the :func:`print` function.
345349
350+
If argument is ``NULL``, return the string ``'<NULL>'``.
351+
346352
.. versionchanged:: 3.4
347353
This function now includes a debug assertion to help ensure that it
348354
does not silently discard an active exception.
@@ -358,6 +364,8 @@ Object Protocol
358364
a TypeError is raised when *o* is an integer instead of a zero-initialized
359365
bytes object.
360366
367+
If argument is ``NULL``, return the :class:`bytes` object ``b'<NULL>'``.
368+
361369
362370
.. c:function:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls)
363371

_sources/c-api/typeobj.rst.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,6 +3055,24 @@ Buffer Object Structures
30553055

30563056
(5) Return ``0``.
30573057

3058+
**Thread safety:**
3059+
3060+
In the :term:`free-threaded build`, implementations must ensure:
3061+
3062+
* The export counter increment in step (3) is atomic.
3063+
3064+
* The underlying buffer data remains valid and at a stable memory
3065+
location for the lifetime of all exports.
3066+
3067+
* For objects that support resizing or reallocation (such as
3068+
:class:`bytearray`), the export counter is checked atomically before
3069+
such operations, and :exc:`BufferError` is raised if exports exist.
3070+
3071+
* The function is safe to call concurrently from multiple threads.
3072+
3073+
See also :ref:`thread-safety-memoryview` for the Python-level
3074+
thread safety guarantees of :class:`memoryview` objects.
3075+
30583076
If *exporter* is part of a chain or tree of buffer providers, two main
30593077
schemes can be used:
30603078

@@ -3100,6 +3118,16 @@ Buffer Object Structures
31003118

31013119
(2) If the counter is ``0``, free all memory associated with *view*.
31023120

3121+
**Thread safety:**
3122+
3123+
In the :term:`free-threaded build`:
3124+
3125+
* The export counter decrement in step (1) must be atomic.
3126+
3127+
* Resource cleanup when the counter reaches zero must be done atomically,
3128+
as the final release may race with concurrent releases from other
3129+
threads and dellocation must only happen once.
3130+
31033131
The exporter MUST use the :c:member:`~Py_buffer.internal` field to keep
31043132
track of buffer-specific resources. This field is guaranteed to remain
31053133
constant, while a consumer MAY pass a copy of the original buffer as the

_sources/c-api/unicode.rst.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,8 +1842,6 @@ object.
18421842
On success, return ``0``.
18431843
On error, set an exception, leave the writer unchanged, and return ``-1``.
18441844
1845-
.. versionadded:: 3.14
1846-
18471845
.. c:function:: int PyUnicodeWriter_WriteWideChar(PyUnicodeWriter *writer, const wchar_t *str, Py_ssize_t size)
18481846
18491847
Write the wide string *str* into *writer*.
@@ -1874,9 +1872,15 @@ object.
18741872
18751873
Call :c:func:`PyObject_Repr` on *obj* and write the output into *writer*.
18761874
1875+
If *obj* is ``NULL``, write the string ``"<NULL>"`` into *writer*.
1876+
18771877
On success, return ``0``.
18781878
On error, set an exception, leave the writer unchanged, and return ``-1``.
18791879
1880+
.. versionchanged:: 3.14.4
1881+
1882+
Added support for ``NULL``.
1883+
18801884
.. c:function:: int PyUnicodeWriter_WriteSubstring(PyUnicodeWriter *writer, PyObject *str, Py_ssize_t start, Py_ssize_t end)
18811885
18821886
Write the substring ``str[start:end]`` into *writer*.

0 commit comments

Comments
 (0)