Skip to content

Commit a66c8cd

Browse files
Merge remote-tracking branch 'upstream/main' into fp_verifier
2 parents 8c9fb56 + 6763d26 commit a66c8cd

File tree

99 files changed

+1822
-1341
lines changed

Some content is hidden

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

99 files changed

+1822
-1341
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ jobs:
369369
sudo xcode-select --switch /Applications/Xcode_15.4.app
370370
371371
- name: Build and test
372-
run: python3 Apple ci iOS --fast-ci --simulator 'iPhone SE (3rd generation),OS=17.5'
372+
run: python3 Platforms/Apple ci iOS --fast-ci --simulator 'iPhone SE (3rd generation),OS=17.5'
373373

374374
build-emscripten:
375375
name: 'Emscripten'

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ repos:
33
rev: a27a2e47c7751b639d2b5badf0ef6ff11fee893f # frozen: v0.15.4
44
hooks:
55
- id: ruff-check
6-
name: Run Ruff (lint) on Apple/
7-
args: [--exit-non-zero-on-fix, --config=Apple/.ruff.toml]
8-
files: ^Apple/
6+
name: Run Ruff (lint) on Platforms/Apple/
7+
args: [--exit-non-zero-on-fix, --config=Platforms/Apple/.ruff.toml]
8+
files: ^Platforms/Apple/
99
- id: ruff-check
1010
name: Run Ruff (lint) on Doc/
1111
args: [--exit-non-zero-on-fix]
@@ -39,9 +39,9 @@ repos:
3939
args: [--exit-non-zero-on-fix, --config=Tools/wasm/.ruff.toml]
4040
files: ^Tools/wasm/
4141
- id: ruff-format
42-
name: Run Ruff (format) on Apple/
43-
args: [--exit-non-zero-on-fix, --config=Apple/.ruff.toml]
44-
files: ^Apple
42+
name: Run Ruff (format) on Platforms/Apple/
43+
args: [--exit-non-zero-on-fix, --config=Platforms/Apple/.ruff.toml]
44+
files: ^Platforms/Apple/
4545
- id: ruff-format
4646
name: Run Ruff (format) on Doc/
4747
args: [--exit-non-zero-on-fix]

Doc/c-api/bytearray.rst

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

Doc/c-api/bytes.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ called with a non-bytes parameter.
127127
Return the bytes representation of object *o* that implements the buffer
128128
protocol.
129129
130+
.. note::
131+
If the object implements the buffer protocol, then the buffer
132+
must not be mutated while the bytes object is being created.
133+
130134
131135
.. c:function:: Py_ssize_t PyBytes_Size(PyObject *o)
132136
@@ -185,13 +189,20 @@ called with a non-bytes parameter.
185189
created, the old reference to *bytes* will still be discarded and the value
186190
of *\*bytes* will be set to ``NULL``; the appropriate exception will be set.
187191
192+
.. note::
193+
If *newpart* implements the buffer protocol, then the buffer
194+
must not be mutated while the new bytes object is being created.
188195
189196
.. c:function:: void PyBytes_ConcatAndDel(PyObject **bytes, PyObject *newpart)
190197
191198
Create a new bytes object in *\*bytes* containing the contents of *newpart*
192199
appended to *bytes*. This version releases the :term:`strong reference`
193200
to *newpart* (i.e. decrements its reference count).
194201
202+
.. note::
203+
If *newpart* implements the buffer protocol, then the buffer
204+
must not be mutated while the new bytes object is being created.
205+
195206
196207
.. c:function:: PyObject* PyBytes_Join(PyObject *sep, PyObject *iterable)
197208
@@ -210,6 +221,9 @@ called with a non-bytes parameter.
210221
211222
.. versionadded:: 3.14
212223
224+
.. note::
225+
If *iterable* objects implement the buffer protocol, then the buffers
226+
must not be mutated while the new bytes object is being created.
213227
214228
.. c:function:: int _PyBytes_Resize(PyObject **bytes, Py_ssize_t newsize)
215229

Doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
('c:type', '__int64'),
178178
('c:type', 'unsigned __int64'),
179179
('c:type', 'double'),
180+
('c:type', '_Float16'),
180181
# Standard C structures
181182
('c:struct', 'in6_addr'),
182183
('c:struct', 'in_addr'),

Doc/data/threadsafety.dat

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,61 @@ PyList_Reverse:shared:
6666
# is a list
6767
PyList_SetSlice:shared:
6868

69-
# Sort - per-object lock held; comparison callbacks may execute
70-
# arbitrary Python code
69+
# Sort - per-object lock held; the list is emptied before sorting
70+
# so other threads may observe an empty list, but they won't see the
71+
# intermediate states of the sort
7172
PyList_Sort:shared:
7273

7374
# Extend - lock target list; also lock source when it is a
7475
# list, set, or dict
7576
PyList_Extend:shared:
77+
78+
# Creation - pure allocation, no shared state
79+
PyBytes_FromString:atomic:
80+
PyBytes_FromStringAndSize:atomic:
81+
PyBytes_DecodeEscape:atomic:
82+
83+
# Creation from formatting C primitives - pure allocation, no shared state
84+
PyBytes_FromFormat:atomic:
85+
PyBytes_FromFormatV:atomic:
86+
87+
# Creation from object - uses buffer protocol so may call arbitrary code;
88+
# safe as long as the buffer is not mutated by another thread during the operation
89+
PyBytes_FromObject:shared:
90+
91+
# Size - uses atomic load on free-threaded builds
92+
PyBytes_Size:atomic:
93+
PyBytes_GET_SIZE:atomic:
94+
95+
# Raw data - no locking; mutating it is unsafe if the bytes object is shared between threads
96+
PyBytes_AsString:compatible:
97+
PyBytes_AS_STRING:compatible:
98+
PyBytes_AsStringAndSize:compatible:
99+
100+
# Concatenation - uses buffer protocol; safe as long as buffer is not mutated by another thread during the operation
101+
PyBytes_Concat:shared:
102+
PyBytes_ConcatAndDel:shared:
103+
PyBytes_Join:shared:
104+
105+
# Resizing - safe if the object is unique
106+
_PyBytes_Resize:distinct:
107+
108+
# Repr - atomic as bytes are immutable
109+
PyBytes_Repr:atomic:
110+
111+
# Creation from object - may call arbitrary code
112+
PyByteArray_FromObject:shared:
113+
114+
# Creation - pure allocation, no shared state
115+
PyByteArray_FromStringAndSize:atomic:
116+
117+
# Concatenation - uses buffer protocol; safe as long as buffer is not mutated by another thread during the operation
118+
PyByteArray_Concat:shared:
119+
120+
# Size - uses atomic load on free-threaded builds
121+
PyByteArray_Size:atomic:
122+
PyByteArray_GET_SIZE:atomic:
123+
124+
# Raw data - no locking; mutating it is unsafe if the bytearray object is shared between threads
125+
PyByteArray_AsString:compatible:
126+
PyByteArray_AS_STRING:compatible:

Doc/library/array.rst

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ The module defines the following type:
133133
The length in bytes of one array item in the internal representation.
134134

135135

136-
.. method:: append(x)
136+
.. method:: append(value, /)
137137

138-
Append a new item with value *x* to the end of the array.
138+
Append a new item with the specified value to the end of the array.
139139

140140

141141
.. method:: buffer_info()
@@ -166,20 +166,20 @@ The module defines the following type:
166166
components (the real part, followed by imaginary part) is preserved.
167167

168168

169-
.. method:: count(x)
169+
.. method:: count(value, /)
170170

171-
Return the number of occurrences of *x* in the array.
171+
Return the number of occurrences of *value* in the array.
172172

173173

174-
.. method:: extend(iterable)
174+
.. method:: extend(iterable, /)
175175

176176
Append items from *iterable* to the end of the array. If *iterable* is another
177177
array, it must have *exactly* the same type code; if not, :exc:`TypeError` will
178178
be raised. If *iterable* is not an array, it must be iterable and its elements
179179
must be the right type to be appended to the array.
180180

181181

182-
.. method:: frombytes(buffer)
182+
.. method:: frombytes(buffer, /)
183183

184184
Appends items from the :term:`bytes-like object`, interpreting
185185
its content as an array of machine values (as if it had been read
@@ -189,55 +189,55 @@ The module defines the following type:
189189
:meth:`!fromstring` is renamed to :meth:`frombytes` for clarity.
190190

191191

192-
.. method:: fromfile(f, n)
192+
.. method:: fromfile(f, n, /)
193193

194194
Read *n* items (as machine values) from the :term:`file object` *f* and append
195195
them to the end of the array. If less than *n* items are available,
196196
:exc:`EOFError` is raised, but the items that were available are still
197197
inserted into the array.
198198

199199

200-
.. method:: fromlist(list)
200+
.. method:: fromlist(list, /)
201201

202202
Append items from the list. This is equivalent to ``for x in list:
203203
a.append(x)`` except that if there is a type error, the array is unchanged.
204204

205205

206-
.. method:: fromunicode(s)
206+
.. method:: fromunicode(ustr, /)
207207

208208
Extends this array with data from the given Unicode string.
209209
The array must have type code ``'u'`` or ``'w'``; otherwise a :exc:`ValueError` is raised.
210210
Use ``array.frombytes(unicodestring.encode(enc))`` to append Unicode data to an
211211
array of some other type.
212212

213213

214-
.. method:: index(x[, start[, stop]])
214+
.. method:: index(value[, start[, stop]])
215215

216216
Return the smallest *i* such that *i* is the index of the first occurrence of
217-
*x* in the array. The optional arguments *start* and *stop* can be
218-
specified to search for *x* within a subsection of the array. Raise
219-
:exc:`ValueError` if *x* is not found.
217+
*value* in the array. The optional arguments *start* and *stop* can be
218+
specified to search for *value* within a subsection of the array. Raise
219+
:exc:`ValueError` if *value* is not found.
220220

221221
.. versionchanged:: 3.10
222222
Added optional *start* and *stop* parameters.
223223

224224

225-
.. method:: insert(i, x)
225+
.. method:: insert(index, value, /)
226226

227-
Insert a new item with value *x* in the array before position *i*. Negative
227+
Insert a new item *value* in the array before position *index*. Negative
228228
values are treated as being relative to the end of the array.
229229

230230

231-
.. method:: pop([i])
231+
.. method:: pop(index=-1, /)
232232

233233
Removes the item with the index *i* from the array and returns it. The optional
234234
argument defaults to ``-1``, so that by default the last item is removed and
235235
returned.
236236

237237

238-
.. method:: remove(x)
238+
.. method:: remove(value, /)
239239

240-
Remove the first occurrence of *x* from the array.
240+
Remove the first occurrence of *value* from the array.
241241

242242

243243
.. method:: clear()
@@ -262,7 +262,7 @@ The module defines the following type:
262262
:meth:`!tostring` is renamed to :meth:`tobytes` for clarity.
263263

264264

265-
.. method:: tofile(f)
265+
.. method:: tofile(f, /)
266266

267267
Write all items (as machine values) to the :term:`file object` *f*.
268268

0 commit comments

Comments
 (0)