Skip to content

Commit 9c4a018

Browse files
authored
Merge branch 'main' into patch-1
2 parents 419a4e0 + 0558275 commit 9c4a018

30 files changed

+384
-60
lines changed

Doc/deprecations/pending-removal-in-3.19.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,19 @@ Pending removal in Python 3.19
66
* Implicitly switching to the MSVC-compatible struct layout by setting
77
:attr:`~ctypes.Structure._pack_` but not :attr:`~ctypes.Structure._layout_`
88
on non-Windows platforms.
9+
10+
* :mod:`hashlib`:
11+
12+
- In hash function constructors such as :func:`~hashlib.new` or the
13+
direct hash-named constructors such as :func:`~hashlib.md5` and
14+
:func:`~hashlib.sha256`, their optional initial data parameter could
15+
also be passed a keyword argument named ``data=`` or ``string=`` in
16+
various :mod:`!hashlib` implementations.
17+
18+
Support for the ``string`` keyword argument name is now deprecated
19+
and slated for removal in Python 3.19.
20+
21+
Before Python 3.13, the ``string`` keyword parameter was not correctly
22+
supported depending on the backend implementation of hash functions.
23+
Prefer passing the initial data as a positional argument for maximum
24+
backwards compatibility.

Doc/library/hashlib.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ accessible by name via :func:`new`. See :data:`algorithms_available`.
9494
OpenSSL does not provide we fall back to a verified implementation from
9595
the `HACL\* project`_.
9696

97+
.. deprecated-removed:: 3.15 3.19
98+
The undocumented ``string`` keyword parameter in :func:`!_hashlib.new`
99+
and hash-named constructors such as :func:`!_md5.md5` is deprecated.
100+
Prefer passing the initial data as a positional argument for maximum
101+
backwards compatibility.
102+
103+
97104
Usage
98105
-----
99106

Doc/library/math.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ noted otherwise, all return values are floats.
5353
:func:`frexp(x) <frexp>` Mantissa and exponent of *x*
5454
:func:`isclose(a, b, rel_tol, abs_tol) <isclose>` Check if the values *a* and *b* are close to each other
5555
:func:`isfinite(x) <isfinite>` Check if *x* is neither an infinity nor a NaN
56+
:func:`isnormal(x) <isnormal>` Check if *x* is a normal number
57+
:func:`issubnormal(x) <issubnormal>` Check if *x* is a subnormal number
5658
:func:`isinf(x) <isinf>` Check if *x* is a positive or negative infinity
5759
:func:`isnan(x) <isnan>` Check if *x* is a NaN (not a number)
5860
:func:`ldexp(x, i) <ldexp>` ``x * (2**i)``, inverse of function :func:`frexp`
@@ -373,6 +375,24 @@ Floating point manipulation functions
373375
.. versionadded:: 3.2
374376

375377

378+
.. function:: isnormal(x)
379+
380+
Return ``True`` if *x* is a normal number, that is a finite
381+
nonzero number that is not a subnormal (see :func:`issubnormal`).
382+
Return ``False`` otherwise.
383+
384+
.. versionadded:: next
385+
386+
387+
.. function:: issubnormal(x)
388+
389+
Return ``True`` if *x* is a subnormal number, that is a finite
390+
nonzero number with a magnitude smaller than the smallest positive normal
391+
number, see :data:`sys.float_info.min`. Return ``False`` otherwise.
392+
393+
.. versionadded:: next
394+
395+
376396
.. function:: isinf(x)
377397

378398
Return ``True`` if *x* is a positive or negative infinity, and

Doc/library/socket.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,7 +1492,7 @@ The :mod:`socket` module also offers various network-related services:
14921492
The *fds* parameter is a sequence of file descriptors.
14931493
Consult :meth:`~socket.sendmsg` for the documentation of these parameters.
14941494

1495-
.. availability:: Unix, Windows, not WASI.
1495+
.. availability:: Unix, not WASI.
14961496

14971497
Unix platforms supporting :meth:`~socket.sendmsg`
14981498
and :const:`SCM_RIGHTS` mechanism.
@@ -1506,9 +1506,9 @@ The :mod:`socket` module also offers various network-related services:
15061506
Return ``(msg, list(fds), flags, addr)``.
15071507
Consult :meth:`~socket.recvmsg` for the documentation of these parameters.
15081508

1509-
.. availability:: Unix, Windows, not WASI.
1509+
.. availability:: Unix, not WASI.
15101510

1511-
Unix platforms supporting :meth:`~socket.sendmsg`
1511+
Unix platforms supporting :meth:`~socket.recvmsg`
15121512
and :const:`SCM_RIGHTS` mechanism.
15131513

15141514
.. versionadded:: 3.9

Doc/library/string.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ The general form of a *standard format specifier* is:
328328
sign: "+" | "-" | " "
329329
width_and_precision: [`width_with_grouping`][`precision_with_grouping`]
330330
width_with_grouping: [`width`][`grouping`]
331-
precision_with_grouping: "." [`precision`][`grouping`]
331+
precision_with_grouping: "." [`precision`][`grouping`] | "." `grouping`
332332
width: `~python-grammar:digit`+
333333
precision: `~python-grammar:digit`+
334334
grouping: "," | "_"

Doc/whatsnew/3.14.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ math
14541454
----
14551455

14561456
* Added more detailed error messages for domain errors in the module.
1457-
(Contributed by by Charlie Zhao and Sergey B Kirpichev in :gh:`101410`.)
1457+
(Contributed by Charlie Zhao and Sergey B Kirpichev in :gh:`101410`.)
14581458

14591459

14601460
mimetypes

Doc/whatsnew/3.15.rst

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ difflib
105105
(Contributed by Jiahao Li in :gh:`134580`.)
106106

107107

108+
math
109+
----
110+
111+
* Add :func:`math.isnormal` and :func:`math.issubnormal` functions.
112+
(Contributed by Sergey B Kirpichev in :gh:`132908`.)
113+
114+
108115
shelve
109116
------
110117

@@ -146,8 +153,20 @@ module_name
146153
Deprecated
147154
==========
148155

149-
* module_name:
150-
TODO
156+
hashlib
157+
-------
158+
159+
* In hash function constructors such as :func:`~hashlib.new` or the
160+
direct hash-named constructors such as :func:`~hashlib.md5` and
161+
:func:`~hashlib.sha256`, their optional initial data parameter could
162+
also be passed a keyword argument named ``data=`` or ``string=`` in
163+
various :mod:`hashlib` implementations.
164+
165+
Support for the ``string`` keyword argument name is now deprecated and
166+
is slated for removal in Python 3.19. Prefer passing the initial data as
167+
a positional argument for maximum backwards compatibility.
168+
169+
(Contributed by Bénédikt Tran in :gh:`134978`.)
151170

152171

153172
.. Add deprecations above alphabetically, not here at the end.

Lib/_pydecimal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6120,9 +6120,9 @@ def _convert_for_comparison(self, other, equality_op=False):
61206120
(?P<no_neg_0>z)?
61216121
(?P<alt>\#)?
61226122
(?P<zeropad>0)?
6123-
(?P<minimumwidth>(?!0)\d+)?
6123+
(?P<minimumwidth>\d+)?
61246124
(?P<thousands_sep>[,_])?
6125-
(?:\.(?P<precision>0|(?!0)\d+))?
6125+
(?:\.(?P<precision>\d+))?
61266126
(?P<type>[eEfFgGn%])?
61276127
\z
61286128
""", re.VERBOSE|re.DOTALL)

Lib/fractions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ def _round_to_figures(n, d, figures):
168168
# A '0' that's *not* followed by another digit is parsed as a minimum width
169169
# rather than a zeropad flag.
170170
(?P<zeropad>0(?=[0-9]))?
171-
(?P<minimumwidth>0|[1-9][0-9]*)?
171+
(?P<minimumwidth>[0-9]+)?
172172
(?P<thousands_sep>[,_])?
173-
(?:\.(?P<precision>0|[1-9][0-9]*))?
173+
(?:\.(?P<precision>[0-9]+))?
174174
(?P<presentation_type>[eEfFgG%])
175175
""", re.DOTALL | re.VERBOSE).fullmatch
176176

Lib/test/test_asyncgen.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,15 @@ async def gen():
20212021
g.athrow(RuntimeError)
20222022
gc_collect()
20232023

2024+
def test_athrow_throws_immediately(self):
2025+
async def gen():
2026+
yield 1
2027+
2028+
g = gen()
2029+
msg = "athrow expected at least 1 argument, got 0"
2030+
with self.assertRaisesRegex(TypeError, msg):
2031+
g.athrow()
2032+
20242033
def test_aclose(self):
20252034
async def gen():
20262035
yield 1

0 commit comments

Comments
 (0)