Skip to content

Commit 9f50bc8

Browse files
committed
Merge branch 'main'
2 parents 055b019 + fb8d8d9 commit 9f50bc8

File tree

327 files changed

+10867
-5256
lines changed

Some content is hidden

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

327 files changed

+10867
-5256
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ jobs:
475475
-x test_subprocess \
476476
-x test_signal \
477477
-x test_sysconfig
478-
- uses: actions/upload-artifact@v6
478+
- uses: actions/upload-artifact@v7
479479
if: always()
480480
with:
481481
name: hypothesis-example-db

.github/workflows/reusable-check-c-api-docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 5
1717
steps:
18-
- uses: actions/checkout@v4
18+
- uses: actions/checkout@v6
1919
with:
2020
persist-credentials: false
21-
- uses: actions/setup-python@v5
21+
- uses: actions/setup-python@v6
2222
with:
2323
python-version: '3.x'
2424
- name: Check for undocumented C APIs

.github/workflows/reusable-cifuzz.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
sanitizer: ${{ inputs.sanitizer }}
3535
- name: Upload crash
3636
if: failure() && steps.build.outcome == 'success'
37-
uses: actions/upload-artifact@v6
37+
uses: actions/upload-artifact@v7
3838
with:
3939
name: ${{ inputs.sanitizer }}-artifacts
4040
path: ./out/artifacts

.github/workflows/reusable-san.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ jobs:
9696
run: find "${GITHUB_WORKSPACE}" -name 'san_log.*' | xargs head -n 1000
9797
- name: Archive logs
9898
if: always()
99-
uses: actions/upload-artifact@v6
99+
uses: actions/upload-artifact@v7
100100
with:
101101
name: >-
102102
${{ inputs.sanitizer }}-logs-${{

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
steps:
1616
- name: "Check PRs"
17-
uses: actions/stale@v9
17+
uses: actions/stale@v10
1818
with:
1919
repo-token: ${{ secrets.GITHUB_TOKEN }}
2020
stale-pr-message: 'This PR is stale because it has been open for 30 days with no activity.'

Doc/c-api/buffer.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,11 @@ Buffer-related functions
500500
*indices* must point to an array of ``view->ndim`` indices.
501501
502502
503-
.. c:function:: int PyBuffer_FromContiguous(const Py_buffer *view, const void *buf, Py_ssize_t len, char fort)
503+
.. c:function:: int PyBuffer_FromContiguous(const Py_buffer *view, const void *buf, Py_ssize_t len, char order)
504504
505505
Copy contiguous *len* bytes from *buf* to *view*.
506-
*fort* can be ``'C'`` or ``'F'`` (for C-style or Fortran-style ordering).
506+
*order* can be ``'C'`` or ``'F'`` or ``'A'`` (for C-style or Fortran-style
507+
ordering or either one).
507508
``0`` is returned on success, ``-1`` on error.
508509
509510

Doc/c-api/file.rst

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

Doc/c-api/float.rst

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -190,24 +190,23 @@ The pack and unpack functions provide an efficient platform-independent way to
190190
store floating-point values as byte strings. The Pack routines produce a bytes
191191
string from a C :c:expr:`double`, and the Unpack routines produce a C
192192
:c:expr:`double` from such a bytes string. The suffix (2, 4 or 8) specifies the
193-
number of bytes in the bytes string.
193+
number of bytes in the bytes string:
194194
195-
On platforms that appear to use IEEE 754 formats these functions work by
196-
copying bits. On other platforms, the 2-byte format is identical to the IEEE
197-
754 binary16 half-precision format, the 4-byte format (32-bit) is identical to
198-
the IEEE 754 binary32 single precision format, and the 8-byte format to the
199-
IEEE 754 binary64 double precision format, although the packing of INFs and
200-
NaNs (if such things exist on the platform) isn't handled correctly, and
201-
attempting to unpack a bytes string containing an IEEE INF or NaN will raise an
202-
exception.
195+
* The 2-byte format is the IEEE 754 binary16 half-precision format.
196+
* The 4-byte format is the IEEE 754 binary32 single-precision format.
197+
* The 8-byte format is the IEEE 754 binary64 double-precision format.
203198
204-
Note that NaNs type may not be preserved on IEEE platforms (signaling NaN become
205-
quiet NaN), for example on x86 systems in 32-bit mode.
199+
The NaN type may not be preserved on some platforms while unpacking (signaling
200+
NaNs become quiet NaNs), for example on x86 systems in 32-bit mode.
206201
202+
It's assumed that the :c:expr:`double` type has the IEEE 754 binary64 double
203+
precision format. What happens if it's not true is partly accidental (alas).
207204
On non-IEEE platforms with more precision, or larger dynamic range, than IEEE
208205
754 supports, not all values can be packed; on non-IEEE platforms with less
209-
precision, or smaller dynamic range, not all values can be unpacked. What
210-
happens in such cases is partly accidental (alas).
206+
precision, or smaller dynamic range, not all values can be unpacked. The
207+
packing of special numbers like INFs and NaNs (if such things exist on the
208+
platform) may not be handled correctly, and attempting to unpack a bytes string
209+
containing an IEEE INF or NaN may raise an exception.
211210
212211
.. versionadded:: 3.11
213212
@@ -216,10 +215,10 @@ Pack functions
216215
217216
The pack routines write 2, 4 or 8 bytes, starting at *p*. *le* is an
218217
:c:expr:`int` argument, non-zero if you want the bytes string in little-endian
219-
format (exponent last, at ``p+1``, ``p+3``, or ``p+6`` ``p+7``), zero if you
220-
want big-endian format (exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN`
221-
constant can be used to use the native endian: it is equal to ``1`` on big
222-
endian processor, or ``0`` on little endian processor.
218+
format (exponent last, at ``p+1``, ``p+3``, or ``p+6`` and ``p+7``), zero if you
219+
want big-endian format (exponent first, at *p*). Use the :c:macro:`!PY_LITTLE_ENDIAN`
220+
constant to select the native endian: it is equal to ``0`` on big
221+
endian processor, or ``1`` on little endian processor.
223222
224223
Return value: ``0`` if all is OK, ``-1`` if error (and an exception is set,
225224
most likely :exc:`OverflowError`).
@@ -236,21 +235,27 @@ most likely :exc:`OverflowError`).
236235
237236
Pack a C double as the IEEE 754 binary64 double precision format.
238237
238+
.. impl-detail::
239+
This function always succeeds in CPython.
240+
239241
240242
Unpack functions
241243
^^^^^^^^^^^^^^^^
242244
243245
The unpack routines read 2, 4 or 8 bytes, starting at *p*. *le* is an
244246
:c:expr:`int` argument, non-zero if the bytes string is in little-endian format
245247
(exponent last, at ``p+1``, ``p+3`` or ``p+6`` and ``p+7``), zero if big-endian
246-
(exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN` constant can be used to
247-
use the native endian: it is equal to ``1`` on big endian processor, or ``0``
248+
(exponent first, at *p*). Use the :c:macro:`!PY_LITTLE_ENDIAN` constant to
249+
select the native endian: it is equal to ``0`` on big endian processor, or ``1``
248250
on little endian processor.
249251
250252
Return value: The unpacked double. On error, this is ``-1.0`` and
251253
:c:func:`PyErr_Occurred` is true (and an exception is set, most likely
252254
:exc:`OverflowError`).
253255
256+
.. impl-detail::
257+
These functions always succeed in CPython.
258+
254259
.. c:function:: double PyFloat_Unpack2(const char *p, int le)
255260
256261
Unpack the IEEE 754 binary16 half-precision format as a C double.

Doc/c-api/list.rst

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

Doc/c-api/object.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ Object Protocol
363363
representation on success, ``NULL`` on failure. This is the equivalent of the
364364
Python expression ``repr(o)``. Called by the :func:`repr` built-in function.
365365
366+
If argument is ``NULL``, return the string ``'<NULL>'``.
367+
366368
.. versionchanged:: 3.4
367369
This function now includes a debug assertion to help ensure that it
368370
does not silently discard an active exception.
@@ -377,6 +379,8 @@ Object Protocol
377379
a string similar to that returned by :c:func:`PyObject_Repr` in Python 2.
378380
Called by the :func:`ascii` built-in function.
379381
382+
If argument is ``NULL``, return the string ``'<NULL>'``.
383+
380384
.. index:: string; PyObject_Str (C function)
381385
382386
@@ -387,6 +391,8 @@ Object Protocol
387391
Python expression ``str(o)``. Called by the :func:`str` built-in function
388392
and, therefore, by the :func:`print` function.
389393
394+
If argument is ``NULL``, return the string ``'<NULL>'``.
395+
390396
.. versionchanged:: 3.4
391397
This function now includes a debug assertion to help ensure that it
392398
does not silently discard an active exception.
@@ -402,6 +408,8 @@ Object Protocol
402408
a TypeError is raised when *o* is an integer instead of a zero-initialized
403409
bytes object.
404410
411+
If argument is ``NULL``, return the :class:`bytes` object ``b'<NULL>'``.
412+
405413
406414
.. c:function:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls)
407415

0 commit comments

Comments
 (0)