Skip to content

Commit 6772a4f

Browse files
committed
Deploy preview for PR 1208 🛫
1 parent 02050f8 commit 6772a4f

File tree

595 files changed

+8149
-9651
lines changed

Some content is hidden

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

595 files changed

+8149
-9651
lines changed

pr-preview/pr-1208/_sources/c-api/dict.rst.txt

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ Dictionary Objects
6565
*key*, return ``1``, otherwise return ``0``. On error, return ``-1``.
6666
This is equivalent to the Python expression ``key in p``.
6767
68+
.. note::
69+
70+
The operation is atomic on :term:`free threading <free-threaded build>`
71+
when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
72+
6873
6974
.. c:function:: int PyDict_ContainsString(PyObject *p, const char *key)
7075
@@ -87,6 +92,11 @@ Dictionary Objects
8792
``0`` on success or ``-1`` on failure. This function *does not* steal a
8893
reference to *val*.
8994
95+
.. note::
96+
97+
The operation is atomic on :term:`free threading <free-threaded build>`
98+
when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
99+
90100
91101
.. c:function:: int PyDict_SetItemString(PyObject *p, const char *key, PyObject *val)
92102
@@ -102,6 +112,11 @@ Dictionary Objects
102112
If *key* is not in the dictionary, :exc:`KeyError` is raised.
103113
Return ``0`` on success or ``-1`` on failure.
104114
115+
.. note::
116+
117+
The operation is atomic on :term:`free threading <free-threaded build>`
118+
when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
119+
105120
106121
.. c:function:: int PyDict_DelItemString(PyObject *p, const char *key)
107122
@@ -120,6 +135,11 @@ Dictionary Objects
120135
* If the key is missing, set *\*result* to ``NULL`` and return ``0``.
121136
* On error, raise an exception and return ``-1``.
122137
138+
.. note::
139+
140+
The operation is atomic on :term:`free threading <free-threaded build>`
141+
when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
142+
123143
.. versionadded:: 3.13
124144
125145
See also the :c:func:`PyObject_GetItem` function.
@@ -137,6 +157,13 @@ Dictionary Objects
137157
:meth:`~object.__eq__` methods are silently ignored.
138158
Prefer the :c:func:`PyDict_GetItemWithError` function instead.
139159
160+
.. note::
161+
162+
In the :term:`free-threaded build`, the returned
163+
:term:`borrowed reference` may become invalid if another thread modifies
164+
the dictionary concurrently. Prefer :c:func:`PyDict_GetItemRef`, which
165+
returns a :term:`strong reference`.
166+
140167
.. versionchanged:: 3.10
141168
Calling this API without an :term:`attached thread state` had been allowed for historical
142169
reason. It is no longer allowed.
@@ -149,6 +176,13 @@ Dictionary Objects
149176
occurred. Return ``NULL`` **without** an exception set if the key
150177
wasn't present.
151178
179+
.. note::
180+
181+
In the :term:`free-threaded build`, the returned
182+
:term:`borrowed reference` may become invalid if another thread modifies
183+
the dictionary concurrently. Prefer :c:func:`PyDict_GetItemRef`, which
184+
returns a :term:`strong reference`.
185+
152186
153187
.. c:function:: PyObject* PyDict_GetItemString(PyObject *p, const char *key)
154188
@@ -164,6 +198,13 @@ Dictionary Objects
164198
Prefer using the :c:func:`PyDict_GetItemWithError` function with your own
165199
:c:func:`PyUnicode_FromString` *key* instead.
166200
201+
.. note::
202+
203+
In the :term:`free-threaded build`, the returned
204+
:term:`borrowed reference` may become invalid if another thread modifies
205+
the dictionary concurrently. Prefer :c:func:`PyDict_GetItemStringRef`,
206+
which returns a :term:`strong reference`.
207+
167208
168209
.. c:function:: int PyDict_GetItemStringRef(PyObject *p, const char *key, PyObject **result)
169210
@@ -184,6 +225,14 @@ Dictionary Objects
184225
185226
.. versionadded:: 3.4
186227
228+
.. note::
229+
230+
In the :term:`free-threaded build`, the returned
231+
:term:`borrowed reference` may become invalid if another thread modifies
232+
the dictionary concurrently. Prefer :c:func:`PyDict_SetDefaultRef`,
233+
which returns a :term:`strong reference`.
234+
235+
187236
188237
.. c:function:: int PyDict_SetDefaultRef(PyObject *p, PyObject *key, PyObject *default_value, PyObject **result)
189238
@@ -203,6 +252,11 @@ Dictionary Objects
203252
These may refer to the same object: in that case you hold two separate
204253
references to it.
205254
255+
.. note::
256+
257+
The operation is atomic on :term:`free threading <free-threaded build>`
258+
when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
259+
206260
.. versionadded:: 3.13
207261
208262
@@ -220,6 +274,11 @@ Dictionary Objects
220274
Similar to :meth:`dict.pop`, but without the default value and
221275
not raising :exc:`KeyError` if the key is missing.
222276
277+
.. note::
278+
279+
The operation is atomic on :term:`free threading <free-threaded build>`
280+
when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
281+
223282
.. versionadded:: 3.13
224283
225284
@@ -336,6 +395,13 @@ Dictionary Objects
336395
only be added if there is not a matching key in *a*. Return ``0`` on
337396
success or ``-1`` if an exception was raised.
338397
398+
.. note::
399+
400+
In the :term:`free-threaded build`, when *b* is a
401+
:class:`dict` (with the standard iterator), both *a* and *b* are locked
402+
for the duration of the operation. When *b* is a non-dict mapping, only
403+
*a* is locked; *b* may be concurrently modified by another thread.
404+
339405
340406
.. c:function:: int PyDict_Update(PyObject *a, PyObject *b)
341407
@@ -345,6 +411,13 @@ Dictionary Objects
345411
argument has no "keys" attribute. Return ``0`` on success or ``-1`` if an
346412
exception was raised.
347413
414+
.. note::
415+
416+
In the :term:`free-threaded build`, when *b* is a
417+
:class:`dict` (with the standard iterator), both *a* and *b* are locked
418+
for the duration of the operation. When *b* is a non-dict mapping, only
419+
*a* is locked; *b* may be concurrently modified by another thread.
420+
348421
349422
.. c:function:: int PyDict_MergeFromSeq2(PyObject *a, PyObject *seq2, int override)
350423
@@ -360,13 +433,27 @@ Dictionary Objects
360433
if override or key not in a:
361434
a[key] = value
362435
436+
.. note::
437+
438+
In the :term:`free-threaded <free threading>` build, only *a* is locked.
439+
The iteration over *seq2* is not synchronized; *seq2* may be concurrently
440+
modified by another thread.
441+
442+
363443
.. c:function:: int PyDict_AddWatcher(PyDict_WatchCallback callback)
364444
365445
Register *callback* as a dictionary watcher. Return a non-negative integer
366446
id which must be passed to future calls to :c:func:`PyDict_Watch`. In case
367447
of error (e.g. no more watcher IDs available), return ``-1`` and set an
368448
exception.
369449
450+
.. note::
451+
452+
This function is not internally synchronized. In the
453+
:term:`free-threaded <free threading>` build, callers should ensure no
454+
concurrent calls to :c:func:`PyDict_AddWatcher` or
455+
:c:func:`PyDict_ClearWatcher` are in progress.
456+
370457
.. versionadded:: 3.12
371458
372459
.. c:function:: int PyDict_ClearWatcher(int watcher_id)
@@ -375,6 +462,13 @@ Dictionary Objects
375462
:c:func:`PyDict_AddWatcher`. Return ``0`` on success, ``-1`` on error (e.g.
376463
if the given *watcher_id* was never registered.)
377464
465+
.. note::
466+
467+
This function is not internally synchronized. In the
468+
:term:`free-threaded <free threading>` build, callers should ensure no
469+
concurrent calls to :c:func:`PyDict_AddWatcher` or
470+
:c:func:`PyDict_ClearWatcher` are in progress.
471+
378472
.. versionadded:: 3.12
379473
380474
.. c:function:: int PyDict_Watch(int watcher_id, PyObject *dict)

pr-preview/pr-1208/_sources/c-api/set.rst.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ the constructor functions work with any iterable Python object.
9292
actually iterable. The constructor is also useful for copying a set
9393
(``c=set(s)``).
9494
95+
.. note::
96+
97+
The operation is atomic on :term:`free threading <free-threaded build>`
98+
when *iterable* is a :class:`set`, :class:`frozenset` or :class:`dict`.
99+
95100
96101
.. c:function:: PyObject* PyFrozenSet_New(PyObject *iterable)
97102
@@ -100,6 +105,11 @@ the constructor functions work with any iterable Python object.
100105
set on success or ``NULL`` on failure. Raise :exc:`TypeError` if *iterable* is
101106
not actually iterable.
102107
108+
.. note::
109+
110+
The operation is atomic on :term:`free threading <free-threaded build>`
111+
when *iterable* is a :class:`set`, :class:`frozenset` or :class:`dict`.
112+
103113
104114
The following functions and macros are available for instances of :class:`set`
105115
or :class:`frozenset` or instances of their subtypes.
@@ -127,6 +137,10 @@ or :class:`frozenset` or instances of their subtypes.
127137
the *key* is unhashable. Raise :exc:`SystemError` if *anyset* is not a
128138
:class:`set`, :class:`frozenset`, or an instance of a subtype.
129139
140+
.. note::
141+
142+
The operation is atomic on :term:`free threading <free-threaded build>`
143+
when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
130144
131145
.. c:function:: int PySet_Add(PyObject *set, PyObject *key)
132146
@@ -138,6 +152,12 @@ or :class:`frozenset` or instances of their subtypes.
138152
:exc:`SystemError` if *set* is not an instance of :class:`set` or its
139153
subtype.
140154
155+
.. note::
156+
157+
The operation is atomic on :term:`free threading <free-threaded build>`
158+
when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
159+
160+
141161
142162
The following functions are available for instances of :class:`set` or its
143163
subtypes but not for instances of :class:`frozenset` or its subtypes.
@@ -152,6 +172,11 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
152172
temporary frozensets. Raise :exc:`SystemError` if *set* is not an
153173
instance of :class:`set` or its subtype.
154174
175+
.. note::
176+
177+
The operation is atomic on :term:`free threading <free-threaded build>`
178+
when *key* is :class:`str`, :class:`int`, :class:`float`, :class:`bool` or :class:`bytes`.
179+
155180
156181
.. c:function:: PyObject* PySet_Pop(PyObject *set)
157182
@@ -167,6 +192,12 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
167192
success. Return ``-1`` and raise :exc:`SystemError` if *set* is not an instance of
168193
:class:`set` or its subtype.
169194
195+
.. note::
196+
197+
In the :term:`free-threaded build`, the set is emptied before its entries
198+
are cleared, so other threads will observe an empty set rather than
199+
intermediate states.
200+
170201
171202
Deprecated API
172203
^^^^^^^^^^^^^^

pr-preview/pr-1208/_sources/c-api/unicode.rst.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,10 @@ object.
18681868
On success, return ``0``.
18691869
On error, set an exception, leave the writer unchanged, and return ``-1``.
18701870
1871+
To write a :class:`str` subclass which overrides the :meth:`~object.__str__`
1872+
method, :c:func:`PyUnicode_FromObject` can be used to get the original
1873+
string.
1874+
18711875
.. c:function:: int PyUnicodeWriter_WriteRepr(PyUnicodeWriter *writer, PyObject *obj)
18721876
18731877
Call :c:func:`PyObject_Repr` on *obj* and write the output into *writer*.

pr-preview/pr-1208/_sources/library/asyncio-eventloop.rst.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,7 @@ Wait until a file descriptor received some data using the
20552055
Set signal handlers for SIGINT and SIGTERM
20562056
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20572057

2058-
(This ``signals`` example only works on Unix.)
2058+
(This ``signal`` example only works on Unix.)
20592059

20602060
Register handlers for signals :const:`~signal.SIGINT` and :const:`~signal.SIGTERM`
20612061
using the :meth:`loop.add_signal_handler` method::

pr-preview/pr-1208/_sources/library/asyncio-future.rst.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ Future Object
196196
Otherwise, change the Future's state to *cancelled*,
197197
schedule the callbacks, and return ``True``.
198198

199+
The optional string argument *msg* is passed as the argument to the
200+
:exc:`CancelledError` exception raised when a cancelled Future
201+
is awaited.
202+
199203
.. versionchanged:: 3.9
200204
Added the *msg* parameter.
201205

pr-preview/pr-1208/_sources/library/glob.rst.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ The :mod:`!glob` module defines the following functions:
8383
This function may return duplicate path names if *pathname*
8484
contains multiple "``**``" patterns and *recursive* is true.
8585

86+
.. note::
87+
Any :exc:`OSError` exceptions raised from scanning the filesystem are
88+
suppressed. This includes :exc:`PermissionError` when accessing
89+
directories without read permission.
90+
8691
.. versionchanged:: 3.5
8792
Support for recursive globs using "``**``".
8893

@@ -106,6 +111,11 @@ The :mod:`!glob` module defines the following functions:
106111
This function may return duplicate path names if *pathname*
107112
contains multiple "``**``" patterns and *recursive* is true.
108113

114+
.. note::
115+
Any :exc:`OSError` exceptions raised from scanning the filesystem are
116+
suppressed. This includes :exc:`PermissionError` when accessing
117+
directories without read permission.
118+
109119
.. versionchanged:: 3.5
110120
Support for recursive globs using "``**``".
111121

pr-preview/pr-1208/_sources/library/importlib.resources.rst.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ not** have to exist as physical files and directories on the file system:
3131
for example, a package and its resources can be imported from a zip file using
3232
:py:mod:`zipimport`.
3333

34+
.. warning::
35+
36+
:mod:`importlib.resources` follows the same security model as the built-in
37+
:func:`open` function. Passing untrusted inputs to the functions
38+
in this module is unsafe.
39+
3440
.. note::
3541

3642
This module provides functionality similar to `pkg_resources

pr-preview/pr-1208/_sources/library/itertools.rst.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ and :term:`generators <generator>` which incur interpreter overhead.
853853

854854
def running_mean(iterable):
855855
"Yield the average of all values seen so far."
856-
# running_mean([8.5, 9.5, 7.5, 6.5]) -> 8.5 9.0 8.5 8.0
856+
# running_mean([8.5, 9.5, 7.5, 6.5]) 8.5 9.0 8.5 8.0
857857
return map(truediv, accumulate(iterable), count(1))
858858

859859
def repeatfunc(function, times=None, *args):
@@ -935,10 +935,10 @@ and :term:`generators <generator>` which incur interpreter overhead.
935935
yield element
936936

937937
def unique(iterable, key=None, reverse=False):
938-
"Yield unique elements in sorted order. Supports unhashable inputs."
939-
# unique([[1, 2], [3, 4], [1, 2]]) → [1, 2] [3, 4]
940-
sequenced = sorted(iterable, key=key, reverse=reverse)
941-
return unique_justseen(sequenced, key=key)
938+
"Yield unique elements in sorted order. Supports unhashable inputs."
939+
# unique([[1, 2], [3, 4], [1, 2]]) → [1, 2] [3, 4]
940+
sequenced = sorted(iterable, key=key, reverse=reverse)
941+
return unique_justseen(sequenced, key=key)
942942

943943
def sliding_window(iterable, n):
944944
"Collect data into overlapping fixed-length chunks or blocks."

pr-preview/pr-1208/_sources/library/multiprocessing.rst.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,8 @@ For an example of the usage of queues for interprocess communication see
932932
standard library's :mod:`queue` module are raised to signal timeouts.
933933

934934
:class:`Queue` implements all the methods of :class:`queue.Queue` except for
935-
:meth:`~queue.Queue.task_done` and :meth:`~queue.Queue.join`.
935+
:meth:`~queue.Queue.task_done`, :meth:`~queue.Queue.join`, and
936+
:meth:`~queue.Queue.shutdown`.
936937

937938
.. method:: qsize()
938939

pr-preview/pr-1208/_sources/library/pathlib.rst.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,11 @@ Reading directories
13651365
``False``, this method follows symlinks except when expanding "``**``"
13661366
wildcards. Set *recurse_symlinks* to ``True`` to always follow symlinks.
13671367

1368+
.. note::
1369+
Any :exc:`OSError` exceptions raised from scanning the filesystem are
1370+
suppressed. This includes :exc:`PermissionError` when accessing
1371+
directories without read permission.
1372+
13681373
.. audit-event:: pathlib.Path.glob self,pattern pathlib.Path.glob
13691374

13701375
.. versionchanged:: 3.12
@@ -1391,6 +1396,11 @@ Reading directories
13911396
The paths are returned in no particular order.
13921397
If you need a specific order, sort the results.
13931398

1399+
.. note::
1400+
Any :exc:`OSError` exceptions raised from scanning the filesystem are
1401+
suppressed. This includes :exc:`PermissionError` when accessing
1402+
directories without read permission.
1403+
13941404
.. seealso::
13951405
:ref:`pathlib-pattern-language` and :meth:`Path.glob` documentation.
13961406

0 commit comments

Comments
 (0)