Skip to content

Commit 999d84d

Browse files
generatedunixname1734921407115435facebook-github-bot
authored andcommitted
Import upstream CPython branch '3.14'
Summary: Python `3.14.0rc1+` (`3.14`) was **published** on 2025-07-31 04:07:44+00:00. # Commit Info Base: (`3.14.0rc1+`) - `38a42fe32c9cdca6e17026bba18c6eb711325f75` (commit date: 2025-07-29 20:10:39+00:00) Imported: (`3.14.0rc1+`) - `3.14` (commit date: 2025-07-31 04:07:44+00:00) # Files added ```javascript Lib/test/test_free_threading/test_bisect.py ``` Reviewed By: itamaro Differential Revision: D79341181 fbshipit-source-id: e531e9a979bed758ed21a5215c086da1a40b8421
1 parent d230562 commit 999d84d

4 files changed

Lines changed: 73 additions & 4 deletions

File tree

Doc/library/bisect.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ method to determine whether a value has been found. Instead, the
2424
functions only call the :meth:`~object.__lt__` method and will return an insertion
2525
point between values in an array.
2626

27+
.. note::
28+
29+
The functions in this module are not thread-safe. If multiple threads
30+
concurrently use :mod:`bisect` functions on the same sequence, this
31+
may result in undefined behaviour. Likewise, if the provided sequence
32+
is mutated by a different thread while a :mod:`bisect` function
33+
is operating on it, the result is undefined. For example, using
34+
:py:func:`~bisect.insort_left` on the same list from multiple threads
35+
may result in the list becoming unsorted.
36+
2737
.. _bisect functions:
2838

2939
The following functions are provided:

Doc/library/http.cookies.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,12 @@ Morsel Objects
148148
in HTTP requests, and is not accessible through JavaScript. This is intended
149149
to mitigate some forms of cross-site scripting.
150150

151-
The attribute :attr:`samesite` specifies that the browser is not allowed to
152-
send the cookie along with cross-site requests. This helps to mitigate CSRF
153-
attacks. Valid values for this attribute are "Strict" and "Lax".
151+
The attribute :attr:`samesite` controls when the browser sends the cookie with
152+
cross-site requests. This helps to mitigate CSRF attacks. Valid values are
153+
"Strict" (only sent with same-site requests), "Lax" (sent with same-site
154+
requests and top-level navigations), and "None" (sent with same-site and
155+
cross-site requests). When using "None", the "secure" attribute must also
156+
be set, as required by modern browsers.
154157

155158
The attribute :attr:`partitioned` indicates to user agents that these
156159
cross-site cookies *should* only be available in the same top-level context

Doc/library/typing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3357,7 +3357,7 @@ Introspection helpers
33573357
with ``T``, unless *include_extras* is set to ``True`` (see
33583358
:class:`Annotated` for more information).
33593359

3360-
See also :func:`inspect.get_annotations`, a lower-level function that
3360+
See also :func:`annotationlib.get_annotations`, a lower-level function that
33613361
returns annotations more directly.
33623362

33633363
.. note::
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import unittest
2+
from test.support import import_helper, threading_helper
3+
import random
4+
5+
py_bisect = import_helper.import_fresh_module('bisect', blocked=['_bisect'])
6+
c_bisect = import_helper.import_fresh_module('bisect', fresh=['_bisect'])
7+
8+
9+
NTHREADS = 4
10+
OBJECT_COUNT = 500
11+
12+
13+
class TestBase:
14+
def do_racing_insort(self, insert_method):
15+
def insert(data):
16+
for _ in range(OBJECT_COUNT):
17+
x = random.randint(-OBJECT_COUNT, OBJECT_COUNT)
18+
insert_method(data, x)
19+
20+
data = list(range(OBJECT_COUNT))
21+
threading_helper.run_concurrently(
22+
worker_func=insert, args=(data,), nthreads=NTHREADS
23+
)
24+
if False:
25+
# These functions are not thread-safe and so the list can become
26+
# unsorted. However, we don't want Python to crash if these
27+
# functions are used concurrently on the same sequence. This
28+
# should also not produce any TSAN warnings.
29+
self.assertTrue(self.is_sorted_ascending(data))
30+
31+
def test_racing_insert_right(self):
32+
self.do_racing_insort(self.mod.insort_right)
33+
34+
def test_racing_insert_left(self):
35+
self.do_racing_insort(self.mod.insort_left)
36+
37+
@staticmethod
38+
def is_sorted_ascending(lst):
39+
"""
40+
Check if the list is sorted in ascending order (non-decreasing).
41+
"""
42+
return all(lst[i - 1] <= lst[i] for i in range(1, len(lst)))
43+
44+
45+
@threading_helper.requires_working_threading()
46+
class TestPyBisect(unittest.TestCase, TestBase):
47+
mod = py_bisect
48+
49+
50+
@threading_helper.requires_working_threading()
51+
class TestCBisect(unittest.TestCase, TestBase):
52+
mod = c_bisect
53+
54+
55+
if __name__ == "__main__":
56+
unittest.main()

0 commit comments

Comments
 (0)