Skip to content

Commit 985c219

Browse files
committed
Merge in the '3.13' branch
2 parents f3aaef0 + bad4bc4 commit 985c219

File tree

18 files changed

+189
-159
lines changed

18 files changed

+189
-159
lines changed

Doc/library/asyncio-task.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,9 @@ Timeouts
758758
An :ref:`asynchronous context manager <async-context-managers>`
759759
for cancelling overdue coroutines.
760760

761+
Prefer using :func:`asyncio.timeout` or :func:`asyncio.timeout_at`
762+
rather than instantiating :class:`!Timeout` directly.
763+
761764
``when`` should be an absolute time at which the context should time out,
762765
as measured by the event loop's clock:
763766

Doc/library/enum.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ Utilities and Decorators
10521052
>>> enum.bin(~10) # ~10 is -11
10531053
'0b1 0101'
10541054

1055-
.. versionadded:: 3.10
1055+
.. versionadded:: 3.11
10561056

10571057
---------------
10581058

Doc/library/secrets.rst

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,39 +62,44 @@ The :mod:`secrets` module provides functions for generating secure
6262
tokens, suitable for applications such as password resets,
6363
hard-to-guess URLs, and similar.
6464

65-
.. function:: token_bytes([nbytes=None])
65+
.. function:: token_bytes(nbytes=None)
6666

6767
Return a random byte string containing *nbytes* number of bytes.
68-
If *nbytes* is ``None`` or not supplied, a reasonable default is
69-
used.
68+
69+
If *nbytes* is not specified or ``None``, :const:`DEFAULT_ENTROPY`
70+
is used instead.
7071

7172
.. doctest::
7273

73-
>>> token_bytes(16) #doctest:+SKIP
74+
>>> token_bytes(16) # doctest: +SKIP
7475
b'\xebr\x17D*t\xae\xd4\xe3S\xb6\xe2\xebP1\x8b'
7576

7677

77-
.. function:: token_hex([nbytes=None])
78+
.. function:: token_hex(nbytes=None)
7879

7980
Return a random text string, in hexadecimal. The string has *nbytes*
80-
random bytes, each byte converted to two hex digits. If *nbytes* is
81-
``None`` or not supplied, a reasonable default is used.
81+
random bytes, each byte converted to two hex digits.
82+
83+
If *nbytes* is not specified or ``None``, :const:`DEFAULT_ENTROPY`
84+
is used instead.
8285

8386
.. doctest::
8487

85-
>>> token_hex(16) #doctest:+SKIP
88+
>>> token_hex(16) # doctest: +SKIP
8689
'f9bf78b9a18ce6d46a0cd2b0b86df9da'
8790

88-
.. function:: token_urlsafe([nbytes=None])
91+
.. function:: token_urlsafe(nbytes=None)
8992

9093
Return a random URL-safe text string, containing *nbytes* random
9194
bytes. The text is Base64 encoded, so on average each byte results
92-
in approximately 1.3 characters. If *nbytes* is ``None`` or not
93-
supplied, a reasonable default is used.
95+
in approximately 1.3 characters.
96+
97+
If *nbytes* is not specified or ``None``, :const:`DEFAULT_ENTROPY`
98+
is used instead.
9499

95100
.. doctest::
96101

97-
>>> token_urlsafe(16) #doctest:+SKIP
102+
>>> token_urlsafe(16) # doctest: +SKIP
98103
'Drmhze6EPcv0fN_81Bj-nA'
99104

100105

@@ -115,11 +120,13 @@ argument to the various ``token_*`` functions. That argument is taken
115120
as the number of bytes of randomness to use.
116121

117122
Otherwise, if no argument is provided, or if the argument is ``None``,
118-
the ``token_*`` functions will use a reasonable default instead.
123+
the ``token_*`` functions uses :const:`DEFAULT_ENTROPY` instead.
119124

120-
.. note::
125+
.. data:: DEFAULT_ENTROPY
126+
127+
Default number of bytes of randomness used by the ``token_*`` functions.
121128

122-
That default is subject to change at any time, including during
129+
The exact value is subject to change at any time, including during
123130
maintenance releases.
124131

125132

Doc/library/stdtypes.rst

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,18 @@ expression support in the :mod:`re` module).
19391939
Return ``True`` if all characters in the string are alphanumeric and there is at
19401940
least one character, ``False`` otherwise. A character ``c`` is alphanumeric if one
19411941
of the following returns ``True``: ``c.isalpha()``, ``c.isdecimal()``,
1942-
``c.isdigit()``, or ``c.isnumeric()``.
1942+
``c.isdigit()``, or ``c.isnumeric()``. For example::
1943+
1944+
.. doctest::
1945+
1946+
>>> 'abc123'.isalnum()
1947+
True
1948+
>>> 'abc123!@#'.isalnum()
1949+
False
1950+
>>> ''.isalnum()
1951+
False
1952+
>>> ' '.isalnum()
1953+
False
19431954

19441955

19451956
.. method:: str.isalpha()
@@ -2231,6 +2242,19 @@ expression support in the :mod:`re` module).
22312242
after the separator. If the separator is not found, return a 3-tuple containing
22322243
the string itself, followed by two empty strings.
22332244

2245+
For example:
2246+
2247+
.. doctest::
2248+
2249+
>>> 'Monty Python'.partition(' ')
2250+
('Monty', ' ', 'Python')
2251+
>>> "Monty Python's Flying Circus".partition(' ')
2252+
('Monty', ' ', "Python's Flying Circus")
2253+
>>> 'Monty Python'.partition('-')
2254+
('Monty Python', '', '')
2255+
2256+
See also :meth:`rpartition`.
2257+
22342258

22352259
.. method:: str.removeprefix(prefix, /)
22362260

0 commit comments

Comments
 (0)