Skip to content

Commit e69f105

Browse files
committed
Merge branch 'main' into annotate-pydict
2 parents 52297b7 + 2c6afb9 commit e69f105

File tree

220 files changed

+6952
-4084
lines changed

Some content is hidden

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

220 files changed

+6952
-4084
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ updates:
1212
update-types:
1313
- "version-update:semver-minor"
1414
- "version-update:semver-patch"
15+
groups:
16+
actions:
17+
patterns:
18+
- "*"
1519
cooldown:
1620
# https://blog.yossarian.net/2025/11/21/We-should-all-be-using-dependency-cooldowns
1721
# Cooldowns protect against supply chain attacks by avoiding the

.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/bytes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,17 @@ Getters
371371
372372
Get the writer size.
373373
374+
The function cannot fail.
375+
374376
.. c:function:: void* PyBytesWriter_GetData(PyBytesWriter *writer)
375377
376378
Get the writer data: start of the internal buffer.
377379
378380
The pointer is valid until :c:func:`PyBytesWriter_Finish` or
379381
:c:func:`PyBytesWriter_Discard` is called on *writer*.
380382
383+
The function cannot fail.
384+
381385
382386
Low-level API
383387
^^^^^^^^^^^^^

Doc/c-api/dict.rst

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ Dictionary objects
4242
enforces read-only behavior. This is normally used to create a view to
4343
prevent modification of the dictionary for non-dynamic class types.
4444
45+
The first argument can be a :class:`dict`, a :class:`frozendict`, or a
46+
mapping.
47+
48+
.. versionchanged:: next
49+
Also accept :class:`frozendict`.
50+
4551
4652
.. c:var:: PyTypeObject PyDictProxy_Type
4753
@@ -68,15 +74,25 @@ Dictionary objects
6874
*key*, return ``1``, otherwise return ``0``. On error, return ``-1``.
6975
This is equivalent to the Python expression ``key in p``.
7076
77+
The first argument can be a :class:`dict` or a :class:`frozendict`.
78+
79+
.. versionchanged:: next
80+
Also accept :class:`frozendict`.
81+
7182
7283
.. c:function:: int PyDict_ContainsString(PyObject *p, const char *key)
7384
7485
This is the same as :c:func:`PyDict_Contains`, but *key* is specified as a
7586
:c:expr:`const char*` UTF-8 encoded bytes string, rather than a
7687
:c:expr:`PyObject*`.
7788
89+
The first argument can be a :class:`dict` or a :class:`frozendict`.
90+
7891
.. versionadded:: 3.13
7992
93+
.. versionchanged:: next
94+
Also accept :class:`frozendict`.
95+
8096
8197
.. c:function:: PyObject* PyDict_Copy(PyObject *p)
8298
@@ -158,8 +174,13 @@ Dictionary objects
158174
* If the key is missing, set *\*result* to ``NULL`` and return ``0``.
159175
* On error, raise an exception and return ``-1``.
160176
177+
The first argument can be a :class:`dict` or a :class:`frozendict`.
178+
161179
.. versionadded:: 3.13
162180
181+
.. versionchanged:: next
182+
Also accept :class:`frozendict`.
183+
163184
See also the :c:func:`PyObject_GetItem` function.
164185
165186
@@ -169,6 +190,8 @@ Dictionary objects
169190
has a key *key*. Return ``NULL`` if the key *key* is missing *without*
170191
setting an exception.
171192
193+
The first argument can be a :class:`dict` or a :class:`frozendict`.
194+
172195
.. note::
173196
174197
Exceptions that occur while this calls :meth:`~object.__hash__` and
@@ -186,6 +209,9 @@ Dictionary objects
186209
Calling this API without an :term:`attached thread state` had been allowed for historical
187210
reason. It is no longer allowed.
188211
212+
.. versionchanged:: next
213+
Also accept :class:`frozendict`.
214+
189215
190216
.. c:function:: PyObject* PyDict_GetItemWithError(PyObject *p, PyObject *key)
191217
@@ -201,6 +227,9 @@ Dictionary objects
201227
the dictionary concurrently. Prefer :c:func:`PyDict_GetItemRef`, which
202228
returns a :term:`strong reference`.
203229
230+
.. versionchanged:: next
231+
Also accept :class:`frozendict`.
232+
204233
205234
.. c:function:: PyObject* PyDict_GetItemString(PyObject *p, const char *key)
206235
@@ -223,6 +252,9 @@ Dictionary objects
223252
the dictionary concurrently. Prefer :c:func:`PyDict_GetItemStringRef`,
224253
which returns a :term:`strong reference`.
225254
255+
.. versionchanged:: next
256+
Also accept :class:`frozendict`.
257+
226258
227259
.. c:function:: int PyDict_GetItemStringRef(PyObject *p, const char *key, PyObject **result)
228260
@@ -232,6 +264,9 @@ Dictionary objects
232264
233265
.. versionadded:: 3.13
234266
267+
.. versionchanged:: next
268+
Also accept :class:`frozendict`.
269+
235270
236271
.. c:function:: PyObject* PyDict_SetDefault(PyObject *p, PyObject *key, PyObject *defaultobj)
237272
@@ -321,17 +356,32 @@ Dictionary objects
321356
322357
Return a :c:type:`PyListObject` containing all the items from the dictionary.
323358
359+
The first argument can be a :class:`dict` or a :class:`frozendict`.
360+
361+
.. versionchanged:: next
362+
Also accept :class:`frozendict`.
363+
324364
325365
.. c:function:: PyObject* PyDict_Keys(PyObject *p)
326366
327367
Return a :c:type:`PyListObject` containing all the keys from the dictionary.
328368
369+
The first argument can be a :class:`dict` or a :class:`frozendict`.
370+
371+
.. versionchanged:: next
372+
Also accept :class:`frozendict`.
373+
329374
330375
.. c:function:: PyObject* PyDict_Values(PyObject *p)
331376
332377
Return a :c:type:`PyListObject` containing all the values from the dictionary
333378
*p*.
334379
380+
The first argument can be a :class:`dict` or a :class:`frozendict`.
381+
382+
.. versionchanged:: next
383+
Also accept :class:`frozendict`.
384+
335385
336386
.. c:function:: Py_ssize_t PyDict_Size(PyObject *p)
337387
@@ -340,11 +390,19 @@ Dictionary objects
340390
Return the number of items in the dictionary. This is equivalent to
341391
``len(p)`` on a dictionary.
342392
393+
The argument can be a :class:`dict` or a :class:`frozendict`.
394+
395+
.. versionchanged:: next
396+
Also accept :class:`frozendict`.
397+
343398
344399
.. c:function:: Py_ssize_t PyDict_GET_SIZE(PyObject *p)
345400
346401
Similar to :c:func:`PyDict_Size`, but without error checking.
347402
403+
.. versionchanged:: next
404+
Also accept :class:`frozendict`.
405+
348406
349407
.. c:function:: int PyDict_Next(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue)
350408
@@ -359,6 +417,8 @@ Dictionary objects
359417
value represents offsets within the internal dictionary structure, and
360418
since the structure is sparse, the offsets are not consecutive.
361419
420+
The first argument can be a :class:`dict` or a :class:`frozendict`.
421+
362422
For example::
363423
364424
PyObject *key, *value;
@@ -392,7 +452,7 @@ Dictionary objects
392452
}
393453
394454
The function is not thread-safe in the :term:`free-threaded <free threading>`
395-
build without external synchronization. You can use
455+
build without external synchronization for a mutable :class:`dict`. You can use
396456
:c:macro:`Py_BEGIN_CRITICAL_SECTION` to lock the dictionary while iterating
397457
over it::
398458
@@ -402,6 +462,8 @@ Dictionary objects
402462
}
403463
Py_END_CRITICAL_SECTION();
404464
465+
The function is thread-safe on a :class:`frozendict`.
466+
405467
.. note::
406468
407469
On the free-threaded build, this function can be used safely inside a
@@ -412,6 +474,9 @@ Dictionary objects
412474
:term:`strong reference <strong reference>` (for example, using
413475
:c:func:`Py_NewRef`).
414476
477+
.. versionchanged:: next
478+
Also accept :class:`frozendict`.
479+
415480
.. c:function:: int PyDict_Merge(PyObject *a, PyObject *b, int override)
416481
417482
Iterate over mapping object *b* adding key-value pairs to dictionary *a*.

Doc/c-api/float.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ NaNs (if such things exist on the platform) isn't handled correctly, and
201201
attempting to unpack a bytes string containing an IEEE INF or NaN will raise an
202202
exception.
203203
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.
204+
Note that NaN type may not be preserved on IEEE platforms (signaling NaNs become
205+
quiet NaNs), for example on x86 systems in 32-bit mode.
206206
207207
On non-IEEE platforms with more precision, or larger dynamic range, than IEEE
208208
754 supports, not all values can be packed; on non-IEEE platforms with less
@@ -216,7 +216,7 @@ Pack functions
216216
217217
The pack routines write 2, 4 or 8 bytes, starting at *p*. *le* is an
218218
: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
219+
format (exponent last, at ``p+1``, ``p+3``, or ``p+6`` and ``p+7``), zero if you
220220
want big-endian format (exponent first, at *p*). The :c:macro:`PY_BIG_ENDIAN`
221221
constant can be used to use the native endian: it is equal to ``1`` on big
222222
endian processor, or ``0`` on little endian processor.

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

0 commit comments

Comments
 (0)