Skip to content

Commit 9b2aedf

Browse files
Merge branch 'main' into fix-empty
2 parents 176e90d + 2359c37 commit 9b2aedf

101 files changed

Lines changed: 1639 additions & 2128 deletions

File tree

Some content is hidden

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

‎.github/workflows/build.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,7 @@ jobs:
266266
# unsupported as it most resembles other 1.1.1-work-a-like ssl APIs
267267
# supported by important vendors such as AWS-LC.
268268
- { name: openssl, version: 1.1.1w }
269-
- { name: openssl, version: 3.4.8 }
270269
- { name: openssl, version: 3.5.10 }
271-
- { name: openssl, version: 3.6.5 }
272270
- { name: openssl, version: 4.0.4 }
273271
## AWS-LC
274272
- { name: aws-lc, version: 5.15.0 }

‎Doc/builtins/stdtypes.rst‎

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,6 +2508,23 @@ expression support in the :mod:`re` module).
25082508
Return ``True`` if all cased characters [4]_ in the string are lowercase and
25092509
there is at least one cased character, ``False`` otherwise.
25102510

2511+
For example:
2512+
2513+
.. doctest::
2514+
2515+
>>> 'banana'.islower()
2516+
True
2517+
>>> 'BANANA'.islower()
2518+
False
2519+
>>> 'baNana'.islower()
2520+
False
2521+
>>> ' '.islower()
2522+
False
2523+
>>> ''.islower()
2524+
False
2525+
2526+
See also :meth:`isupper` and :meth:`lower`.
2527+
25112528

25122529
.. method:: str.isnumeric()
25132530

@@ -2612,6 +2629,10 @@ expression support in the :mod:`re` module).
26122629
Return ``True`` if all cased characters [4]_ in the string are uppercase and
26132630
there is at least one cased character, ``False`` otherwise.
26142631

2632+
For example:
2633+
2634+
.. doctest::
2635+
26152636
>>> 'BANANA'.isupper()
26162637
True
26172638
>>> 'banana'.isupper()
@@ -2620,7 +2641,10 @@ expression support in the :mod:`re` module).
26202641
False
26212642
>>> ' '.isupper()
26222643
False
2644+
>>> ''.isupper()
2645+
False
26232646

2647+
See also :meth:`islower` and :meth:`upper`.
26242648

26252649

26262650
.. _meth-str-join:
@@ -2672,10 +2696,25 @@ expression support in the :mod:`re` module).
26722696
>>> 'Lower Method Example'.lower()
26732697
'lower method example'
26742698

2699+
Note that ``s.lower().islower()`` might be ``False`` if ``s``
2700+
contains uncased characters or if the Unicode category of the resulting
2701+
character(s) is not "Lu" (Letter, uppercase), but for instance "Lt" (Letter,
2702+
titlecase).
2703+
2704+
For example, see the word "Python" written in Punjabi:
2705+
2706+
.. doctest::
2707+
2708+
>>> 'ازگر'.lower().islower()
2709+
False
2710+
2711+
26752712
The lowercasing algorithm used is `described in section 3.13.2 'Default Case
26762713
Conversion' of the Unicode Standard
26772714
<https://www.unicode.org/versions/Unicode18.0.0/core-spec/chapter-3/#G34078>`__.
26782715

2716+
See also :meth:`islower` and :meth:`upper`.
2717+
26792718

26802719
.. method:: str.lstrip(chars=None, /)
26812720

@@ -3179,15 +3218,33 @@ expression support in the :mod:`re` module).
31793218
.. method:: str.upper()
31803219

31813220
Return a copy of the string with all the cased characters [4]_ converted to
3182-
uppercase. Note that ``s.upper().isupper()`` might be ``False`` if ``s``
3221+
uppercase.
3222+
3223+
For example:
3224+
3225+
.. doctest::
3226+
3227+
>>> 'Upper Method Example'.upper()
3228+
'UPPER METHOD EXAMPLE'
3229+
3230+
Note that ``s.upper().isupper()`` might be ``False`` if ``s``
31833231
contains no cased characters or if the Unicode category of the resulting
3184-
character(s) is not "Lu" (Letter, uppercase), but e.g. "Lt" (Letter,
3232+
character(s) is not "Lu" (Letter, uppercase), but for instance "Lt" (Letter,
31853233
titlecase).
31863234

3235+
For example, see the word "Python" written in Punjabi:
3236+
3237+
.. doctest::
3238+
3239+
>>> 'ازگر'.upper().isupper()
3240+
False
3241+
31873242
The uppercasing algorithm used is `described in section 3.13.2 'Default Case
31883243
Conversion' of the Unicode Standard
31893244
<https://www.unicode.org/versions/Unicode18.0.0/core-spec/chapter-3/#G34078>`__.
31903245

3246+
See also :meth:`isupper` and :meth:`lower`.
3247+
31913248

31923249
.. method:: str.zfill(width, /)
31933250

‎Doc/library/random.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ be found in any statistics text.
300300

301301
Return the next random floating-point number in the range ``0.0 <= X < 1.0``
302302

303+
The boolean expression ``random() < p`` is :const:`True` with probability
304+
``p``.
305+
303306

304307
.. function:: uniform(a, b)
305308

‎Include/internal/pycore_global_objects_fini_generated.h‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Include/internal/pycore_global_strings.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ struct _Py_global_strings {
329329
STRUCT_FOR_ID(ast)
330330
STRUCT_FOR_ID(athrow)
331331
STRUCT_FOR_ID(attr)
332+
STRUCT_FOR_ID(attrib)
332333
STRUCT_FOR_ID(attribute)
333334
STRUCT_FOR_ID(autocommit)
334335
STRUCT_FOR_ID(backtick)

‎Include/internal/pycore_interp_structs.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,11 @@ struct _is {
861861
uint64_t next_unique_id;
862862
/* The linked list of threads, newest first. */
863863
PyThreadState *head;
864+
/* The linked list of thread states that have been created but are
865+
not bound to an OS thread yet. They are moved to `head` once
866+
they are bound, so that `head` only lists fully initialized
867+
thread states. Protected by HEAD_LOCK. */
868+
PyThreadState *pending;
864869
_PyThreadStateImpl *preallocated;
865870
/* The thread currently executing in the __main__ module, if any. */
866871
PyThreadState *main;

‎Include/internal/pycore_runtime_init_generated.h‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Include/internal/pycore_setobject.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ PyAPI_DATA(PyObject *) _PySet_Dummy;
3030

3131
PyAPI_FUNC(int) _PySet_Contains(PySetObject *so, PyObject *key);
3232

33-
// Clears the set without acquiring locks. Used by _PyCode_Fini.
33+
// Clears the set without acquiring locks. Used by _PyCode_Fini().
3434
extern void _PySet_ClearInternal(PySetObject *so);
3535

3636
PyAPI_FUNC(int) _PySet_AddTakeRef(PySetObject *so, PyObject *key);

‎Include/internal/pycore_unicodeobject_generated.h‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Lib/asyncio/tasks.py‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -581,17 +581,11 @@ def __init__(self, aws, timeout):
581581
self._timeout_handle = None
582582

583583
loop = events.get_event_loop()
584-
# The iterator may be created outside of a running event loop and
585-
# then driven with loop.run_until_complete(), in which case there
586-
# is no current task to record as the waiter.
587-
if events._get_running_loop() is loop:
588-
self._cur_task = current_task(loop)
589-
else:
590-
self._cur_task = None
591584
todo = {ensure_future(aw, loop=loop) for aw in set(aws)}
585+
self._waiter = loop.create_future()
592586
for f in todo:
593587
f.add_done_callback(self._handle_completion)
594-
futures.future_add_to_awaited_by(f, self._cur_task)
588+
futures.future_add_to_awaited_by(f, self._waiter)
595589
if todo and timeout is not None:
596590
self._timeout_handle = (
597591
loop.call_later(timeout, self._handle_timeout)
@@ -622,15 +616,15 @@ def __next__(self):
622616
def _handle_timeout(self):
623617
for f in self._todo:
624618
f.remove_done_callback(self._handle_completion)
625-
futures.future_discard_from_awaited_by(f, self._cur_task)
619+
futures.future_discard_from_awaited_by(f, self._waiter)
626620
self._done.put_nowait(None) # Sentinel for _wait_for_one().
627621
self._todo.clear() # Can't do todo.remove(f) in the loop.
628622

629623
def _handle_completion(self, f):
630624
if not self._todo:
631625
return # _handle_timeout() was here first.
632626
self._todo.remove(f)
633-
futures.future_discard_from_awaited_by(f, self._cur_task)
627+
futures.future_discard_from_awaited_by(f, self._waiter)
634628
self._done.put_nowait(f)
635629
if not self._todo and self._timeout_handle is not None:
636630
self._timeout_handle.cancel()
@@ -639,11 +633,18 @@ async def _wait_for_one(self, resolve=False):
639633
# Wait for the next future to be done and return it unless resolve is
640634
# set, in which case return either the result of the future or raise
641635
# an exception.
636+
edge_added = False
642637
try:
638+
cur_task = current_task() if self._done.empty() else None
639+
futures.future_add_to_awaited_by(self._waiter, cur_task)
640+
edge_added = True
643641
f = await self._done.get()
644642
except:
645643
self._todo_left += 1
646644
raise
645+
finally:
646+
if edge_added:
647+
futures.future_discard_from_awaited_by(self._waiter, cur_task)
647648
if f is None:
648649
# Dummy value from _handle_timeout().
649650
raise exceptions.TimeoutError

0 commit comments

Comments
 (0)