Skip to content

Commit

Permalink
Merge branch 'main' into gh-126255-temp-workaround-embed-test-failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Eclips4 authored Nov 1, 2024
2 parents 52e7fa3 + c84a136 commit b5c3459
Show file tree
Hide file tree
Showing 24 changed files with 201 additions and 267 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ Objects/exceptions.c @iritkatriel
**/sha* @gpshead @tiran
Modules/md5* @gpshead @tiran
**/*blake* @gpshead @tiran
Modules/_blake2/** @gpshead @tiran
Modules/_hacl/** @gpshead

# logging
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/jit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ concurrency:
jobs:
interpreter:
name: Interpreter (Debug)
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -85,19 +85,19 @@ jobs:
compiler: clang
- target: x86_64-unknown-linux-gnu/gcc
architecture: x86_64
runner: ubuntu-latest
runner: ubuntu-22.04
compiler: gcc
- target: x86_64-unknown-linux-gnu/clang
architecture: x86_64
runner: ubuntu-latest
runner: ubuntu-22.04
compiler: clang
- target: aarch64-unknown-linux-gnu/gcc
architecture: aarch64
runner: ubuntu-latest
runner: ubuntu-22.04
compiler: gcc
- target: aarch64-unknown-linux-gnu/clang
architecture: aarch64
runner: ubuntu-latest
runner: ubuntu-22.04
compiler: clang
env:
CC: ${{ matrix.compiler }}
Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/pending-removal-in-3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Pending removal in Python 3.14
:meth:`~pathlib.PurePath.relative_to`: passing additional arguments is
deprecated.

* :mod:`pkgutil`: :func:`~pkgutil.find_loader` and :func:`~pkgutil.get_loader`
* :mod:`pkgutil`: :func:`!pkgutil.find_loader` and :func:!pkgutil.get_loader`
now raise :exc:`DeprecationWarning`;
use :func:`importlib.util.find_spec` instead.
(Contributed by Nikita Sobolev in :gh:`97850`.)
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ using function-call syntax::
... BLUE = 3

>>> # functional syntax
>>> Color = Enum('Color', ['RED', 'GREEN', 'BLUE'])
>>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])

Even though we can use :keyword:`class` syntax to create Enums, Enums
are not normal Python classes. See
Expand Down
92 changes: 89 additions & 3 deletions Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,92 @@ The following functions are provided by this module. Except when explicitly
noted otherwise, all return values are floats.


==================================================== ============================================
**Number-theoretic and representation functions**
--------------------------------------------------------------------------------------------------
:func:`ceil(x) <ceil>` Ceiling of *x*, the smallest integer greater than or equal to *x*
:func:`comb(n, k) <comb>` Number of ways to choose *k* items from *n* items without repetition and without order
:func:`copysign(x, y) <copysign>` Magnitude (absolute value) of *x* with the sign of *y*
:func:`fabs(x) <fabs>` Absolute value of *x*
:func:`factorial(n) <factorial>` *n* factorial
:func:`floor (x) <floor>` Floor of *x*, the largest integer less than or equal to *x*
:func:`fma(x, y, z) <fma>` Fused multiply-add operation: ``(x * y) + z``
:func:`fmod(x, y) <fmod>` Remainder of division ``x / y``
:func:`frexp(x) <frexp>` Mantissa and exponent of *x*
:func:`fsum(iterable) <fsum>` Sum of values in the input *iterable*
:func:`gcd(*integers) <gcd>` Greatest common divisor of the integer arguments
:func:`isclose(a, b, rel_tol, abs_tol) <isclose>` Check if the values *a* and *b* are close to each other
:func:`isfinite(x) <isfinite>` Check if *x* is neither an infinity nor a NaN
:func:`isinf(x) <isinf>` Check if *x* is a positive or negative infinity
:func:`isnan(x) <isnan>` Check if *x* is a NaN (not a number)
:func:`isqrt(n) <isqrt>` Integer square root of a nonnegative integer *n*
:func:`lcm(*integers) <lcm>` Least common multiple of the integer arguments
:func:`ldexp(x, i) <ldexp>` ``x * (2**i)``, inverse of function :func:`frexp`
:func:`modf(x) <modf>` Fractional and integer parts of *x*
:func:`nextafter(x, y, steps) <nextafter>` Floating-point value *steps* steps after *x* towards *y*
:func:`perm(n, k) <perm>` Number of ways to choose *k* items from *n* items without repetition and with order
:func:`prod(iterable, start) <prod>` Product of elements in the input *iterable* with a *start* value
:func:`remainder(x, y) <remainder>` Remainder of *x* with respect to *y*
:func:`sumprod(p, q) <sumprod>` Sum of products from two iterables *p* and *q*
:func:`trunc(x) <trunc>` Integer part of *x*
:func:`ulp(x) <ulp>` Value of the least significant bit of *x*

**Power and logarithmic functions**
--------------------------------------------------------------------------------------------------
:func:`cbrt(x) <cbrt>` Cube root of *x*
:func:`exp(x) <exp>` *e* raised to the power *x*
:func:`exp2(x) <exp2>` *2* raised to the power *x*
:func:`expm1(x) <expm1>` *e* raised to the power *x*, minus 1
:func:`log(x, base) <log>` Logarithm of *x* to the given base (*e* by default)
:func:`log1p(x) <log1p>` Natural logarithm of *1+x* (base *e*)
:func:`log2(x) <log2>` Base-2 logarithm of *x*
:func:`log10(x) <log10>` Base-10 logarithm of *x*
:func:`pow(x, y) <math.pow>` *x* raised to the power *y*
:func:`sqrt(x) <sqrt>` Square root of *x*

**Trigonometric functions**
--------------------------------------------------------------------------------------------------
:func:`acos(x) <acos>` Arc cosine of *x*
:func:`asin(x) <asin>` Arc sine of *x*
:func:`atan(x) <atan>` Arc tangent of *x*
:func:`atan2(y, x) <atan2>` ``atan(y / x)``
:func:`cos(x) <cos>` Cosine of *x*
:func:`dist(p, q) <dist>` Euclidean distance between two points *p* and *q* given as an iterable of coordinates
:func:`hypot(*coordinates) <hypot>` Euclidean norm of an iterable of coordinates
:func:`sin(x) <sin>` Sine of *x*
:func:`tan(x) <tan>` Tangent of *x*

**Angular conversion**
--------------------------------------------------------------------------------------------------
:func:`degrees(x) <degrees>` Convert angle *x* from radians to degrees
:func:`radians(x) <radians>` Convert angle *x* from degrees to radians

**Hyperbolic functions**
--------------------------------------------------------------------------------------------------
:func:`acosh(x) <acosh>` Inverse hyperbolic cosine of *x*
:func:`asinh(x) <asinh>` Inverse hyperbolic sine of *x*
:func:`atanh(x) <atanh>` Inverse hyperbolic tangent of *x*
:func:`cosh(x) <cosh>` Hyperbolic cosine of *x*
:func:`sinh(x) <sinh>` Hyperbolic sine of *x*
:func:`tanh(x) <tanh>` Hyperbolic tangent of *x*

**Special functions**
--------------------------------------------------------------------------------------------------
:func:`erf(x) <erf>` `Error function <https://en.wikipedia.org/wiki/Error_function>`_ at *x*
:func:`erfc(x) <erfc>` `Complementary error function <https://en.wikipedia.org/wiki/Error_function>`_ at *x*
:func:`gamma(x) <gamma>` `Gamma function <https://en.wikipedia.org/wiki/Gamma_function>`_ at *x*
:func:`lgamma(x) <lgamma>` Natural logarithm of the absolute value of the `Gamma function <https://en.wikipedia.org/wiki/Gamma_function>`_ at *x*

**Constants**
--------------------------------------------------------------------------------------------------
:data:`pi` *π* = 3.141592...
:data:`e` *e* = 2.718281...
:data:`tau` *τ* = 2\ *π* = 6.283185...
:data:`inf` Positive infinity
:data:`nan` "Not a number" (NaN)
==================================================== ============================================


Number-theoretic and representation functions
---------------------------------------------

Expand Down Expand Up @@ -447,11 +533,11 @@ Power and logarithmic functions

.. function:: pow(x, y)

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

Unlike the built-in ``**`` operator, :func:`math.pow` converts both
Expand Down
40 changes: 0 additions & 40 deletions Doc/library/pkgutil.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,6 @@ support.
this function to raise an exception (in line with :func:`os.path.isdir`
behavior).

.. function:: find_loader(fullname)

Retrieve a module :term:`loader` for the given *fullname*.

This is a backwards compatibility wrapper around
:func:`importlib.util.find_spec` that converts most failures to
:exc:`ImportError` and only returns the loader rather than the full
:class:`importlib.machinery.ModuleSpec`.

.. versionchanged:: 3.3
Updated to be based directly on :mod:`importlib` rather than relying
on the package internal :pep:`302` import emulation.

.. versionchanged:: 3.4
Updated to be based on :pep:`451`

.. deprecated-removed:: 3.12 3.14
Use :func:`importlib.util.find_spec` instead.


.. function:: get_importer(path_item)

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


.. function:: get_loader(module_or_name)

Get a :term:`loader` object for *module_or_name*.

If the module or package is accessible via the normal import mechanism, a
wrapper around the relevant part of that machinery is returned. Returns
``None`` if the module cannot be found or imported. If the named module is
not already imported, its containing package (if any) is imported, in order
to establish the package ``__path__``.

.. versionchanged:: 3.3
Updated to be based directly on :mod:`importlib` rather than relying
on the package internal :pep:`302` import emulation.

.. versionchanged:: 3.4
Updated to be based on :pep:`451`

.. deprecated-removed:: 3.12 3.14
Use :func:`importlib.util.find_spec` instead.


.. function:: iter_importers(fullname='')

Yield :term:`finder` objects for the given module name.
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ Deprecated
your code *requires* ``'fork'``. See :ref:`contexts and start methods
<multiprocessing-start-methods>`.

* :mod:`pkgutil`: :func:`pkgutil.find_loader` and :func:`pkgutil.get_loader`
* :mod:`pkgutil`: :func:`!pkgutil.find_loader` and :func:`!pkgutil.get_loader`
are deprecated and will be removed in Python 3.14;
use :func:`importlib.util.find_spec` instead.
(Contributed by Nikita Sobolev in :gh:`97850`.)
Expand Down
7 changes: 7 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,13 @@ pathlib
:meth:`~pathlib.PurePath.is_relative_to`. In previous versions, any such
arguments are joined onto *other*.

pkgutil
-------

* Remove deprecated :func:`!pkgutil.get_loader` and :func:`!pkgutil.find_loader`.
These had previously raised a :exc:`DeprecationWarning` since Python 3.12.
(Contributed by Bénédikt Tran in :gh:`97850`.)

pty
---

Expand Down
13 changes: 4 additions & 9 deletions Lib/glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,6 @@ def concat_path(path, text):
"""
raise NotImplementedError

@staticmethod
def parse_entry(entry):
"""Returns the path of an entry yielded from scandir().
"""
raise NotImplementedError

# High-level methods

def compile(self, pat):
Expand Down Expand Up @@ -438,6 +432,7 @@ def select_wildcard(path, exists=False):
except OSError:
pass
else:
prefix = self.add_slash(path)
for entry in entries:
if match is None or match(entry.name):
if dir_only:
Expand All @@ -446,7 +441,7 @@ def select_wildcard(path, exists=False):
continue
except OSError:
continue
entry_path = self.parse_entry(entry)
entry_path = self.concat_path(prefix, entry.name)
if dir_only:
yield from select_next(entry_path, exists=True)
else:
Expand Down Expand Up @@ -495,6 +490,7 @@ def select_recursive_step(stack, match_pos):
except OSError:
pass
else:
prefix = self.add_slash(path)
for entry in entries:
is_dir = False
try:
Expand All @@ -504,7 +500,7 @@ def select_recursive_step(stack, match_pos):
pass

if is_dir or not dir_only:
entry_path = self.parse_entry(entry)
entry_path = self.concat_path(prefix, entry.name)
if match is None or match(str(entry_path), match_pos):
if dir_only:
yield from select_next(entry_path, exists=True)
Expand Down Expand Up @@ -533,7 +529,6 @@ class _StringGlobber(_GlobberBase):
"""
lexists = staticmethod(os.path.lexists)
scandir = staticmethod(os.scandir)
parse_entry = operator.attrgetter('path')
concat_path = operator.add

if os.name == 'nt':
Expand Down
36 changes: 13 additions & 23 deletions Lib/pathlib/_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,13 @@ class PathGlobber(_GlobberBase):

lexists = operator.methodcaller('exists', follow_symlinks=False)
add_slash = operator.methodcaller('joinpath', '')

@staticmethod
def scandir(path):
"""Emulates os.scandir(), which returns an object that can be used as
a context manager. This method is called by walk() and glob().
"""
import contextlib
return contextlib.nullcontext(path.iterdir())
scandir = operator.methodcaller('scandir')

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

@staticmethod
def parse_entry(entry):
"""Returns the path of an entry yielded from scandir()."""
return entry


class PurePathBase:
"""Base class for pure path objects.
Expand Down Expand Up @@ -705,16 +693,18 @@ def walk(self, top_down=True, on_error=None, follow_symlinks=False):
if not top_down:
paths.append((path, dirnames, filenames))
try:
for child in path.iterdir():
try:
if child.is_dir(follow_symlinks=follow_symlinks):
if not top_down:
paths.append(child)
dirnames.append(child.name)
else:
filenames.append(child.name)
except OSError:
filenames.append(child.name)
with path.scandir() as entries:
for entry in entries:
name = entry.name
try:
if entry.is_dir(follow_symlinks=follow_symlinks):
if not top_down:
paths.append(path.joinpath(name))
dirnames.append(name)
else:
filenames.append(name)
except OSError:
filenames.append(name)
except OSError as error:
if on_error is not None:
on_error(error)
Expand Down
Loading

0 comments on commit b5c3459

Please sign in to comment.