Skip to content

Commit

Permalink
Merge branch 'main' into pthread_jit_write_protect_np
Browse files Browse the repository at this point in the history
  • Loading branch information
diegorusso authored Nov 4, 2024
2 parents 363a96c + 3032fcd commit 4e5a0b5
Show file tree
Hide file tree
Showing 48 changed files with 1,047 additions and 245 deletions.
3 changes: 0 additions & 3 deletions Doc/deprecations/pending-removal-in-3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ Pending removal in Python 3.14
if :ref:`named placeholders <sqlite3-placeholders>` are used and
*parameters* is a sequence instead of a :class:`dict`.

* date and datetime adapter, date and timestamp converter:
see the :mod:`sqlite3` documentation for suggested replacement recipes.

* :class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was
deprecated in :pep:`626`
since 3.10 and was planned to be removed in 3.12,
Expand Down
5 changes: 2 additions & 3 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ an event loop:
instead of using these lower level functions to manually create and close an
event loop.

.. deprecated:: 3.12
Deprecation warning is emitted if there is no current event loop.
In some future Python release this will become an error.
.. versionchanged:: 3.14
Raises a :exc:`RuntimeError` if there is no current event loop.

.. function:: set_event_loop(loop)

Expand Down
8 changes: 3 additions & 5 deletions Doc/library/asyncio-policy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,9 @@ asyncio ships with the following built-in policies:

On Windows, :class:`ProactorEventLoop` is now used by default.

.. deprecated:: 3.12
The :meth:`get_event_loop` method of the default asyncio policy now emits
a :exc:`DeprecationWarning` if there is no current event loop set and it
decides to create one.
In some future Python release this will become an error.
.. versionchanged:: 3.14
The :meth:`get_event_loop` method of the default asyncio policy now
raises a :exc:`RuntimeError` if there is no set event loop.


.. class:: WindowsSelectorEventLoopPolicy
Expand Down
18 changes: 10 additions & 8 deletions Doc/library/cmath.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,19 +221,21 @@ Classification functions
``False`` otherwise.

Whether or not two values are considered close is determined according to
given absolute and relative tolerances.
given absolute and relative tolerances. If no errors occur, the result will
be: ``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``.

*rel_tol* is the relative tolerance -- it is the maximum allowed difference
between *a* and *b*, relative to the larger absolute value of *a* or *b*.
For example, to set a tolerance of 5%, pass ``rel_tol=0.05``. The default
tolerance is ``1e-09``, which assures that the two values are the same
within about 9 decimal digits. *rel_tol* must be greater than zero.

*abs_tol* is the minimum absolute tolerance -- useful for comparisons near
zero. *abs_tol* must be at least zero.

If no errors occur, the result will be:
``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``.
within about 9 decimal digits. *rel_tol* must be nonnegative and less
than ``1.0``.

*abs_tol* is the absolute tolerance; it defaults to ``0.0`` and it must be
nonnegative. When comparing ``x`` to ``0.0``, ``isclose(x, 0)`` is computed
as ``abs(x) <= rel_tol * abs(x)``, which is ``False`` for any ``x`` and
rel_tol less than ``1.0``. So add an appropriate positive abs_tol argument
to the call.

The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be
handled according to IEEE rules. Specifically, ``NaN`` is not considered
Expand Down
11 changes: 8 additions & 3 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1205,14 +1205,19 @@ are always available. They are listed here in alphabetical order.
unchanged from previous versions.


.. function:: map(function, iterable, *iterables)
.. function:: map(function, iterable, /, *iterables, strict=False)

Return an iterator that applies *function* to every item of *iterable*,
yielding the results. If additional *iterables* arguments are passed,
*function* must take that many arguments and is applied to the items from all
iterables in parallel. With multiple iterables, the iterator stops when the
shortest iterable is exhausted. For cases where the function inputs are
already arranged into argument tuples, see :func:`itertools.starmap`\.
shortest iterable is exhausted. If *strict* is ``True`` and one of the
iterables is exhausted before the others, a :exc:`ValueError` is raised. For
cases where the function inputs are already arranged into argument tuples,
see :func:`itertools.starmap`.

.. versionchanged:: 3.14
Added the *strict* parameter.


.. function:: max(iterable, *, key=None)
Expand Down
12 changes: 10 additions & 2 deletions Doc/library/getopt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ exception:

An example using only Unix style options:

.. doctest::

>>> import getopt
>>> args = '-a -b -cfoo -d bar a1 a2'.split()
>>> args
Expand All @@ -109,6 +111,8 @@ An example using only Unix style options:

Using long option names is equally easy:

.. doctest::

>>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'
>>> args = s.split()
>>> args
Expand All @@ -120,7 +124,9 @@ Using long option names is equally easy:
>>> args
['a1', 'a2']

In a script, typical usage is something like this::
In a script, typical usage is something like this:

.. testcode::

import getopt, sys

Expand Down Expand Up @@ -150,7 +156,9 @@ In a script, typical usage is something like this::
main()

Note that an equivalent command line interface could be produced with less code
and more informative help and error messages by using the :mod:`argparse` module::
and more informative help and error messages by using the :mod:`argparse` module:

.. testcode::

import argparse

Expand Down
18 changes: 10 additions & 8 deletions Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,21 @@ Number-theoretic and representation functions
``False`` otherwise.

Whether or not two values are considered close is determined according to
given absolute and relative tolerances.
given absolute and relative tolerances. If no errors occur, the result will
be: ``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``.

*rel_tol* is the relative tolerance -- it is the maximum allowed difference
between *a* and *b*, relative to the larger absolute value of *a* or *b*.
For example, to set a tolerance of 5%, pass ``rel_tol=0.05``. The default
tolerance is ``1e-09``, which assures that the two values are the same
within about 9 decimal digits. *rel_tol* must be greater than zero.

*abs_tol* is the minimum absolute tolerance -- useful for comparisons near
zero. *abs_tol* must be at least zero.

If no errors occur, the result will be:
``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``.
within about 9 decimal digits. *rel_tol* must be nonnegative and less
than ``1.0``.

*abs_tol* is the absolute tolerance; it defaults to ``0.0`` and it must be
nonnegative. When comparing ``x`` to ``0.0``, ``isclose(x, 0)`` is computed
as ``abs(x) <= rel_tol * abs(x)``, which is ``False`` for any ``x`` and
rel_tol less than ``1.0``. So add an appropriate positive abs_tol argument
to the call.

The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be
handled according to IEEE rules. Specifically, ``NaN`` is not considered
Expand Down
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ Improved error messages
Other language changes
======================

* The :func:`map` built-in now has an optional keyword-only *strict* flag
like :func:`zip` to check that all the iterables are of equal length.
(Contributed by Wannes Boeykens in :gh:`119793`.)

* Incorrect usage of :keyword:`await` and asynchronous comprehensions
is now detected even if the code is optimized away by the :option:`-O`
command-line option. For example, ``python -O -c 'assert await 1'``
Expand Down Expand Up @@ -576,6 +580,11 @@ asyncio

(Contributed by Kumar Aditya in :gh:`120804`.)

* Removed implicit creation of event loop by :func:`asyncio.get_event_loop`.
It now raises a :exc:`RuntimeError` if there is no current event loop.
(Contributed by Kumar Aditya in :gh:`126353`.)


collections.abc
---------------

Expand Down
24 changes: 0 additions & 24 deletions Lib/asyncio/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,6 @@ class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):

class _Local(threading.local):
_loop = None
_set_called = False

def __init__(self):
self._local = self._Local()
Expand All @@ -678,28 +677,6 @@ def get_event_loop(self):
Returns an instance of EventLoop or raises an exception.
"""
if (self._local._loop is None and
not self._local._set_called and
threading.current_thread() is threading.main_thread()):
stacklevel = 2
try:
f = sys._getframe(1)
except AttributeError:
pass
else:
# Move up the call stack so that the warning is attached
# to the line outside asyncio itself.
while f:
module = f.f_globals.get('__name__')
if not (module == 'asyncio' or module.startswith('asyncio.')):
break
f = f.f_back
stacklevel += 1
import warnings
warnings.warn('There is no current event loop',
DeprecationWarning, stacklevel=stacklevel)
self.set_event_loop(self.new_event_loop())

if self._local._loop is None:
raise RuntimeError('There is no current event loop in thread %r.'
% threading.current_thread().name)
Expand All @@ -708,7 +685,6 @@ def get_event_loop(self):

def set_event_loop(self, loop):
"""Set the event loop."""
self._local._set_called = True
if loop is not None and not isinstance(loop, AbstractEventLoop):
raise TypeError(f"loop must be an instance of AbstractEventLoop or None, not '{type(loop).__name__}'")
self._local._loop = loop
Expand Down
7 changes: 2 additions & 5 deletions Lib/getopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@
__all__ = ["GetoptError","error","getopt","gnu_getopt"]

import os
try:
from gettext import gettext as _
except ImportError:
# Bootstrapping Python: gettext's dependencies not built yet
def _(s): return s
from gettext import gettext as _


class GetoptError(Exception):
opt = ''
Expand Down
15 changes: 2 additions & 13 deletions Lib/optparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@

import sys, os
import textwrap
from gettext import gettext as _, ngettext


def _repr(self):
return "<%s at 0x%x: %s>" % (self.__class__.__name__, id(self), self)
Expand All @@ -86,19 +88,6 @@ def _repr(self):
# Id: help.py 527 2006-07-23 15:21:30Z greg
# Id: errors.py 509 2006-04-20 00:58:24Z gward

try:
from gettext import gettext, ngettext
except ImportError:
def gettext(message):
return message

def ngettext(singular, plural, n):
if n == 1:
return singular
return plural

_ = gettext


class OptParseError (Exception):
def __init__(self, msg):
Expand Down
14 changes: 8 additions & 6 deletions Lib/test/libregrtest/findtests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
import unittest
from collections.abc import Container

from test import support

Expand Down Expand Up @@ -34,7 +35,7 @@ def findtestdir(path: StrPath | None = None) -> StrPath:
return path or os.path.dirname(os.path.dirname(__file__)) or os.curdir


def findtests(*, testdir: StrPath | None = None, exclude=(),
def findtests(*, testdir: StrPath | None = None, exclude: Container[str] = (),
split_test_dirs: set[TestName] = SPLITTESTDIRS,
base_mod: str = "") -> TestList:
"""Return a list of all applicable test modules."""
Expand All @@ -60,8 +61,9 @@ def findtests(*, testdir: StrPath | None = None, exclude=(),
return sorted(tests)


def split_test_packages(tests, *, testdir: StrPath | None = None, exclude=(),
split_test_dirs=SPLITTESTDIRS):
def split_test_packages(tests, *, testdir: StrPath | None = None,
exclude: Container[str] = (),
split_test_dirs=SPLITTESTDIRS) -> list[TestName]:
testdir = findtestdir(testdir)
splitted = []
for name in tests:
Expand All @@ -75,9 +77,9 @@ def split_test_packages(tests, *, testdir: StrPath | None = None, exclude=(),
return splitted


def _list_cases(suite):
def _list_cases(suite: unittest.TestSuite) -> None:
for test in suite:
if isinstance(test, unittest.loader._FailedTest):
if isinstance(test, unittest.loader._FailedTest): # type: ignore[attr-defined]
continue
if isinstance(test, unittest.TestSuite):
_list_cases(test)
Expand All @@ -87,7 +89,7 @@ def _list_cases(suite):

def list_cases(tests: TestTuple, *,
match_tests: TestFilter | None = None,
test_dir: StrPath | None = None):
test_dir: StrPath | None = None) -> None:
support.verbose = False
set_match_tests(match_tests)

Expand Down
Loading

0 comments on commit 4e5a0b5

Please sign in to comment.