Skip to content

Commit b5c3459

Browse files
authored
Merge branch 'main' into gh-126255-temp-workaround-embed-test-failure
2 parents 52e7fa3 + c84a136 commit b5c3459

File tree

24 files changed

+201
-267
lines changed

24 files changed

+201
-267
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ Objects/exceptions.c @iritkatriel
8888
**/sha* @gpshead @tiran
8989
Modules/md5* @gpshead @tiran
9090
**/*blake* @gpshead @tiran
91-
Modules/_blake2/** @gpshead @tiran
9291
Modules/_hacl/** @gpshead
9392

9493
# logging

.github/workflows/jit.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ concurrency:
2828
jobs:
2929
interpreter:
3030
name: Interpreter (Debug)
31-
runs-on: ubuntu-latest
31+
runs-on: ubuntu-22.04
3232
timeout-minutes: 90
3333
steps:
3434
- uses: actions/checkout@v4
@@ -85,19 +85,19 @@ jobs:
8585
compiler: clang
8686
- target: x86_64-unknown-linux-gnu/gcc
8787
architecture: x86_64
88-
runner: ubuntu-latest
88+
runner: ubuntu-22.04
8989
compiler: gcc
9090
- target: x86_64-unknown-linux-gnu/clang
9191
architecture: x86_64
92-
runner: ubuntu-latest
92+
runner: ubuntu-22.04
9393
compiler: clang
9494
- target: aarch64-unknown-linux-gnu/gcc
9595
architecture: aarch64
96-
runner: ubuntu-latest
96+
runner: ubuntu-22.04
9797
compiler: gcc
9898
- target: aarch64-unknown-linux-gnu/clang
9999
architecture: aarch64
100-
runner: ubuntu-latest
100+
runner: ubuntu-22.04
101101
compiler: clang
102102
env:
103103
CC: ${{ matrix.compiler }}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Pending removal in Python 3.14
8585
:meth:`~pathlib.PurePath.relative_to`: passing additional arguments is
8686
deprecated.
8787

88-
* :mod:`pkgutil`: :func:`~pkgutil.find_loader` and :func:`~pkgutil.get_loader`
88+
* :mod:`pkgutil`: :func:`!pkgutil.find_loader` and :func:!pkgutil.get_loader`
8989
now raise :exc:`DeprecationWarning`;
9090
use :func:`importlib.util.find_spec` instead.
9191
(Contributed by Nikita Sobolev in :gh:`97850`.)

Doc/library/enum.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ using function-call syntax::
4444
... BLUE = 3
4545

4646
>>> # functional syntax
47-
>>> Color = Enum('Color', ['RED', 'GREEN', 'BLUE'])
47+
>>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])
4848

4949
Even though we can use :keyword:`class` syntax to create Enums, Enums
5050
are not normal Python classes. See

Doc/library/math.rst

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,92 @@ The following functions are provided by this module. Except when explicitly
2626
noted otherwise, all return values are floats.
2727

2828

29+
==================================================== ============================================
30+
**Number-theoretic and representation functions**
31+
--------------------------------------------------------------------------------------------------
32+
:func:`ceil(x) <ceil>` Ceiling of *x*, the smallest integer greater than or equal to *x*
33+
:func:`comb(n, k) <comb>` Number of ways to choose *k* items from *n* items without repetition and without order
34+
:func:`copysign(x, y) <copysign>` Magnitude (absolute value) of *x* with the sign of *y*
35+
:func:`fabs(x) <fabs>` Absolute value of *x*
36+
:func:`factorial(n) <factorial>` *n* factorial
37+
:func:`floor (x) <floor>` Floor of *x*, the largest integer less than or equal to *x*
38+
:func:`fma(x, y, z) <fma>` Fused multiply-add operation: ``(x * y) + z``
39+
:func:`fmod(x, y) <fmod>` Remainder of division ``x / y``
40+
:func:`frexp(x) <frexp>` Mantissa and exponent of *x*
41+
:func:`fsum(iterable) <fsum>` Sum of values in the input *iterable*
42+
:func:`gcd(*integers) <gcd>` Greatest common divisor of the integer arguments
43+
:func:`isclose(a, b, rel_tol, abs_tol) <isclose>` Check if the values *a* and *b* are close to each other
44+
:func:`isfinite(x) <isfinite>` Check if *x* is neither an infinity nor a NaN
45+
:func:`isinf(x) <isinf>` Check if *x* is a positive or negative infinity
46+
:func:`isnan(x) <isnan>` Check if *x* is a NaN (not a number)
47+
:func:`isqrt(n) <isqrt>` Integer square root of a nonnegative integer *n*
48+
:func:`lcm(*integers) <lcm>` Least common multiple of the integer arguments
49+
:func:`ldexp(x, i) <ldexp>` ``x * (2**i)``, inverse of function :func:`frexp`
50+
:func:`modf(x) <modf>` Fractional and integer parts of *x*
51+
:func:`nextafter(x, y, steps) <nextafter>` Floating-point value *steps* steps after *x* towards *y*
52+
:func:`perm(n, k) <perm>` Number of ways to choose *k* items from *n* items without repetition and with order
53+
:func:`prod(iterable, start) <prod>` Product of elements in the input *iterable* with a *start* value
54+
:func:`remainder(x, y) <remainder>` Remainder of *x* with respect to *y*
55+
:func:`sumprod(p, q) <sumprod>` Sum of products from two iterables *p* and *q*
56+
:func:`trunc(x) <trunc>` Integer part of *x*
57+
:func:`ulp(x) <ulp>` Value of the least significant bit of *x*
58+
59+
**Power and logarithmic functions**
60+
--------------------------------------------------------------------------------------------------
61+
:func:`cbrt(x) <cbrt>` Cube root of *x*
62+
:func:`exp(x) <exp>` *e* raised to the power *x*
63+
:func:`exp2(x) <exp2>` *2* raised to the power *x*
64+
:func:`expm1(x) <expm1>` *e* raised to the power *x*, minus 1
65+
:func:`log(x, base) <log>` Logarithm of *x* to the given base (*e* by default)
66+
:func:`log1p(x) <log1p>` Natural logarithm of *1+x* (base *e*)
67+
:func:`log2(x) <log2>` Base-2 logarithm of *x*
68+
:func:`log10(x) <log10>` Base-10 logarithm of *x*
69+
:func:`pow(x, y) <math.pow>` *x* raised to the power *y*
70+
:func:`sqrt(x) <sqrt>` Square root of *x*
71+
72+
**Trigonometric functions**
73+
--------------------------------------------------------------------------------------------------
74+
:func:`acos(x) <acos>` Arc cosine of *x*
75+
:func:`asin(x) <asin>` Arc sine of *x*
76+
:func:`atan(x) <atan>` Arc tangent of *x*
77+
:func:`atan2(y, x) <atan2>` ``atan(y / x)``
78+
:func:`cos(x) <cos>` Cosine of *x*
79+
:func:`dist(p, q) <dist>` Euclidean distance between two points *p* and *q* given as an iterable of coordinates
80+
:func:`hypot(*coordinates) <hypot>` Euclidean norm of an iterable of coordinates
81+
:func:`sin(x) <sin>` Sine of *x*
82+
:func:`tan(x) <tan>` Tangent of *x*
83+
84+
**Angular conversion**
85+
--------------------------------------------------------------------------------------------------
86+
:func:`degrees(x) <degrees>` Convert angle *x* from radians to degrees
87+
:func:`radians(x) <radians>` Convert angle *x* from degrees to radians
88+
89+
**Hyperbolic functions**
90+
--------------------------------------------------------------------------------------------------
91+
:func:`acosh(x) <acosh>` Inverse hyperbolic cosine of *x*
92+
:func:`asinh(x) <asinh>` Inverse hyperbolic sine of *x*
93+
:func:`atanh(x) <atanh>` Inverse hyperbolic tangent of *x*
94+
:func:`cosh(x) <cosh>` Hyperbolic cosine of *x*
95+
:func:`sinh(x) <sinh>` Hyperbolic sine of *x*
96+
:func:`tanh(x) <tanh>` Hyperbolic tangent of *x*
97+
98+
**Special functions**
99+
--------------------------------------------------------------------------------------------------
100+
:func:`erf(x) <erf>` `Error function <https://en.wikipedia.org/wiki/Error_function>`_ at *x*
101+
:func:`erfc(x) <erfc>` `Complementary error function <https://en.wikipedia.org/wiki/Error_function>`_ at *x*
102+
:func:`gamma(x) <gamma>` `Gamma function <https://en.wikipedia.org/wiki/Gamma_function>`_ at *x*
103+
:func:`lgamma(x) <lgamma>` Natural logarithm of the absolute value of the `Gamma function <https://en.wikipedia.org/wiki/Gamma_function>`_ at *x*
104+
105+
**Constants**
106+
--------------------------------------------------------------------------------------------------
107+
:data:`pi` *π* = 3.141592...
108+
:data:`e` *e* = 2.718281...
109+
:data:`tau` *τ* = 2\ *π* = 6.283185...
110+
:data:`inf` Positive infinity
111+
:data:`nan` "Not a number" (NaN)
112+
==================================================== ============================================
113+
114+
29115
Number-theoretic and representation functions
30116
---------------------------------------------
31117

@@ -447,11 +533,11 @@ Power and logarithmic functions
447533

448534
.. function:: pow(x, y)
449535

450-
Return ``x`` raised to the power ``y``. Exceptional cases follow
536+
Return *x* raised to the power *y*. Exceptional cases follow
451537
the IEEE 754 standard as far as possible. In particular,
452538
``pow(1.0, x)`` and ``pow(x, 0.0)`` always return ``1.0``, even
453-
when ``x`` is a zero or a NaN. If both ``x`` and ``y`` are finite,
454-
``x`` is negative, and ``y`` is not an integer then ``pow(x, y)``
539+
when *x* is a zero or a NaN. If both *x* and *y* are finite,
540+
*x* is negative, and *y* is not an integer then ``pow(x, y)``
455541
is undefined, and raises :exc:`ValueError`.
456542

457543
Unlike the built-in ``**`` operator, :func:`math.pow` converts both

Doc/library/pkgutil.rst

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,6 @@ support.
4949
this function to raise an exception (in line with :func:`os.path.isdir`
5050
behavior).
5151

52-
.. function:: find_loader(fullname)
53-
54-
Retrieve a module :term:`loader` for the given *fullname*.
55-
56-
This is a backwards compatibility wrapper around
57-
:func:`importlib.util.find_spec` that converts most failures to
58-
:exc:`ImportError` and only returns the loader rather than the full
59-
:class:`importlib.machinery.ModuleSpec`.
60-
61-
.. versionchanged:: 3.3
62-
Updated to be based directly on :mod:`importlib` rather than relying
63-
on the package internal :pep:`302` import emulation.
64-
65-
.. versionchanged:: 3.4
66-
Updated to be based on :pep:`451`
67-
68-
.. deprecated-removed:: 3.12 3.14
69-
Use :func:`importlib.util.find_spec` instead.
70-
7152

7253
.. function:: get_importer(path_item)
7354

@@ -84,27 +65,6 @@ support.
8465
on the package internal :pep:`302` import emulation.
8566

8667

87-
.. function:: get_loader(module_or_name)
88-
89-
Get a :term:`loader` object for *module_or_name*.
90-
91-
If the module or package is accessible via the normal import mechanism, a
92-
wrapper around the relevant part of that machinery is returned. Returns
93-
``None`` if the module cannot be found or imported. If the named module is
94-
not already imported, its containing package (if any) is imported, in order
95-
to establish the package ``__path__``.
96-
97-
.. versionchanged:: 3.3
98-
Updated to be based directly on :mod:`importlib` rather than relying
99-
on the package internal :pep:`302` import emulation.
100-
101-
.. versionchanged:: 3.4
102-
Updated to be based on :pep:`451`
103-
104-
.. deprecated-removed:: 3.12 3.14
105-
Use :func:`importlib.util.find_spec` instead.
106-
107-
10868
.. function:: iter_importers(fullname='')
10969

11070
Yield :term:`finder` objects for the given module name.

Doc/whatsnew/3.12.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ Deprecated
12291229
your code *requires* ``'fork'``. See :ref:`contexts and start methods
12301230
<multiprocessing-start-methods>`.
12311231

1232-
* :mod:`pkgutil`: :func:`pkgutil.find_loader` and :func:`pkgutil.get_loader`
1232+
* :mod:`pkgutil`: :func:`!pkgutil.find_loader` and :func:`!pkgutil.get_loader`
12331233
are deprecated and will be removed in Python 3.14;
12341234
use :func:`importlib.util.find_spec` instead.
12351235
(Contributed by Nikita Sobolev in :gh:`97850`.)

Doc/whatsnew/3.14.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,13 @@ pathlib
621621
:meth:`~pathlib.PurePath.is_relative_to`. In previous versions, any such
622622
arguments are joined onto *other*.
623623

624+
pkgutil
625+
-------
626+
627+
* Remove deprecated :func:`!pkgutil.get_loader` and :func:`!pkgutil.find_loader`.
628+
These had previously raised a :exc:`DeprecationWarning` since Python 3.12.
629+
(Contributed by Bénédikt Tran in :gh:`97850`.)
630+
624631
pty
625632
---
626633

Lib/glob.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,6 @@ def concat_path(path, text):
364364
"""
365365
raise NotImplementedError
366366

367-
@staticmethod
368-
def parse_entry(entry):
369-
"""Returns the path of an entry yielded from scandir().
370-
"""
371-
raise NotImplementedError
372-
373367
# High-level methods
374368

375369
def compile(self, pat):
@@ -438,6 +432,7 @@ def select_wildcard(path, exists=False):
438432
except OSError:
439433
pass
440434
else:
435+
prefix = self.add_slash(path)
441436
for entry in entries:
442437
if match is None or match(entry.name):
443438
if dir_only:
@@ -446,7 +441,7 @@ def select_wildcard(path, exists=False):
446441
continue
447442
except OSError:
448443
continue
449-
entry_path = self.parse_entry(entry)
444+
entry_path = self.concat_path(prefix, entry.name)
450445
if dir_only:
451446
yield from select_next(entry_path, exists=True)
452447
else:
@@ -495,6 +490,7 @@ def select_recursive_step(stack, match_pos):
495490
except OSError:
496491
pass
497492
else:
493+
prefix = self.add_slash(path)
498494
for entry in entries:
499495
is_dir = False
500496
try:
@@ -504,7 +500,7 @@ def select_recursive_step(stack, match_pos):
504500
pass
505501

506502
if is_dir or not dir_only:
507-
entry_path = self.parse_entry(entry)
503+
entry_path = self.concat_path(prefix, entry.name)
508504
if match is None or match(str(entry_path), match_pos):
509505
if dir_only:
510506
yield from select_next(entry_path, exists=True)
@@ -533,7 +529,6 @@ class _StringGlobber(_GlobberBase):
533529
"""
534530
lexists = staticmethod(os.path.lexists)
535531
scandir = staticmethod(os.scandir)
536-
parse_entry = operator.attrgetter('path')
537532
concat_path = operator.add
538533

539534
if os.name == 'nt':

Lib/pathlib/_abc.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,13 @@ class PathGlobber(_GlobberBase):
9494

9595
lexists = operator.methodcaller('exists', follow_symlinks=False)
9696
add_slash = operator.methodcaller('joinpath', '')
97-
98-
@staticmethod
99-
def scandir(path):
100-
"""Emulates os.scandir(), which returns an object that can be used as
101-
a context manager. This method is called by walk() and glob().
102-
"""
103-
import contextlib
104-
return contextlib.nullcontext(path.iterdir())
97+
scandir = operator.methodcaller('scandir')
10598

10699
@staticmethod
107100
def concat_path(path, text):
108101
"""Appends text to the given path."""
109102
return path.with_segments(path._raw_path + text)
110103

111-
@staticmethod
112-
def parse_entry(entry):
113-
"""Returns the path of an entry yielded from scandir()."""
114-
return entry
115-
116104

117105
class PurePathBase:
118106
"""Base class for pure path objects.
@@ -705,16 +693,18 @@ def walk(self, top_down=True, on_error=None, follow_symlinks=False):
705693
if not top_down:
706694
paths.append((path, dirnames, filenames))
707695
try:
708-
for child in path.iterdir():
709-
try:
710-
if child.is_dir(follow_symlinks=follow_symlinks):
711-
if not top_down:
712-
paths.append(child)
713-
dirnames.append(child.name)
714-
else:
715-
filenames.append(child.name)
716-
except OSError:
717-
filenames.append(child.name)
696+
with path.scandir() as entries:
697+
for entry in entries:
698+
name = entry.name
699+
try:
700+
if entry.is_dir(follow_symlinks=follow_symlinks):
701+
if not top_down:
702+
paths.append(path.joinpath(name))
703+
dirnames.append(name)
704+
else:
705+
filenames.append(name)
706+
except OSError:
707+
filenames.append(name)
718708
except OSError as error:
719709
if on_error is not None:
720710
on_error(error)

0 commit comments

Comments
 (0)