Skip to content

Commit 4e5a0b5

Browse files
authored
Merge branch 'main' into pthread_jit_write_protect_np
2 parents 363a96c + 3032fcd commit 4e5a0b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1047
-245
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ Pending removal in Python 3.14
103103
if :ref:`named placeholders <sqlite3-placeholders>` are used and
104104
*parameters* is a sequence instead of a :class:`dict`.
105105

106-
* date and datetime adapter, date and timestamp converter:
107-
see the :mod:`sqlite3` documentation for suggested replacement recipes.
108-
109106
* :class:`types.CodeType`: Accessing :attr:`~codeobject.co_lnotab` was
110107
deprecated in :pep:`626`
111108
since 3.10 and was planned to be removed in 3.12,

Doc/library/asyncio-eventloop.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ an event loop:
5959
instead of using these lower level functions to manually create and close an
6060
event loop.
6161

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

6665
.. function:: set_event_loop(loop)
6766

Doc/library/asyncio-policy.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,9 @@ asyncio ships with the following built-in policies:
9797

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

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

106104

107105
.. class:: WindowsSelectorEventLoopPolicy

Doc/library/cmath.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,19 +221,21 @@ Classification functions
221221
``False`` otherwise.
222222

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

226227
*rel_tol* is the relative tolerance -- it is the maximum allowed difference
227228
between *a* and *b*, relative to the larger absolute value of *a* or *b*.
228229
For example, to set a tolerance of 5%, pass ``rel_tol=0.05``. The default
229230
tolerance is ``1e-09``, which assures that the two values are the same
230-
within about 9 decimal digits. *rel_tol* must be greater than zero.
231-
232-
*abs_tol* is the minimum absolute tolerance -- useful for comparisons near
233-
zero. *abs_tol* must be at least zero.
234-
235-
If no errors occur, the result will be:
236-
``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``.
231+
within about 9 decimal digits. *rel_tol* must be nonnegative and less
232+
than ``1.0``.
233+
234+
*abs_tol* is the absolute tolerance; it defaults to ``0.0`` and it must be
235+
nonnegative. When comparing ``x`` to ``0.0``, ``isclose(x, 0)`` is computed
236+
as ``abs(x) <= rel_tol * abs(x)``, which is ``False`` for any ``x`` and
237+
rel_tol less than ``1.0``. So add an appropriate positive abs_tol argument
238+
to the call.
237239

238240
The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be
239241
handled according to IEEE rules. Specifically, ``NaN`` is not considered

Doc/library/functions.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,14 +1205,19 @@ are always available. They are listed here in alphabetical order.
12051205
unchanged from previous versions.
12061206

12071207

1208-
.. function:: map(function, iterable, *iterables)
1208+
.. function:: map(function, iterable, /, *iterables, strict=False)
12091209

12101210
Return an iterator that applies *function* to every item of *iterable*,
12111211
yielding the results. If additional *iterables* arguments are passed,
12121212
*function* must take that many arguments and is applied to the items from all
12131213
iterables in parallel. With multiple iterables, the iterator stops when the
1214-
shortest iterable is exhausted. For cases where the function inputs are
1215-
already arranged into argument tuples, see :func:`itertools.starmap`\.
1214+
shortest iterable is exhausted. If *strict* is ``True`` and one of the
1215+
iterables is exhausted before the others, a :exc:`ValueError` is raised. For
1216+
cases where the function inputs are already arranged into argument tuples,
1217+
see :func:`itertools.starmap`.
1218+
1219+
.. versionchanged:: 3.14
1220+
Added the *strict* parameter.
12161221

12171222

12181223
.. function:: max(iterable, *, key=None)

Doc/library/getopt.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ exception:
9797

9898
An example using only Unix style options:
9999

100+
.. doctest::
101+
100102
>>> import getopt
101103
>>> args = '-a -b -cfoo -d bar a1 a2'.split()
102104
>>> args
@@ -109,6 +111,8 @@ An example using only Unix style options:
109111

110112
Using long option names is equally easy:
111113

114+
.. doctest::
115+
112116
>>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'
113117
>>> args = s.split()
114118
>>> args
@@ -120,7 +124,9 @@ Using long option names is equally easy:
120124
>>> args
121125
['a1', 'a2']
122126

123-
In a script, typical usage is something like this::
127+
In a script, typical usage is something like this:
128+
129+
.. testcode::
124130

125131
import getopt, sys
126132

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

152158
Note that an equivalent command line interface could be produced with less code
153-
and more informative help and error messages by using the :mod:`argparse` module::
159+
and more informative help and error messages by using the :mod:`argparse` module:
160+
161+
.. testcode::
154162

155163
import argparse
156164

Doc/library/math.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,19 +244,21 @@ Number-theoretic and representation functions
244244
``False`` otherwise.
245245

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

249250
*rel_tol* is the relative tolerance -- it is the maximum allowed difference
250251
between *a* and *b*, relative to the larger absolute value of *a* or *b*.
251252
For example, to set a tolerance of 5%, pass ``rel_tol=0.05``. The default
252253
tolerance is ``1e-09``, which assures that the two values are the same
253-
within about 9 decimal digits. *rel_tol* must be greater than zero.
254-
255-
*abs_tol* is the minimum absolute tolerance -- useful for comparisons near
256-
zero. *abs_tol* must be at least zero.
257-
258-
If no errors occur, the result will be:
259-
``abs(a-b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)``.
254+
within about 9 decimal digits. *rel_tol* must be nonnegative and less
255+
than ``1.0``.
256+
257+
*abs_tol* is the absolute tolerance; it defaults to ``0.0`` and it must be
258+
nonnegative. When comparing ``x`` to ``0.0``, ``isclose(x, 0)`` is computed
259+
as ``abs(x) <= rel_tol * abs(x)``, which is ``False`` for any ``x`` and
260+
rel_tol less than ``1.0``. So add an appropriate positive abs_tol argument
261+
to the call.
260262

261263
The IEEE 754 special values of ``NaN``, ``inf``, and ``-inf`` will be
262264
handled according to IEEE rules. Specifically, ``NaN`` is not considered

Doc/whatsnew/3.14.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ Improved error messages
175175
Other language changes
176176
======================
177177

178+
* The :func:`map` built-in now has an optional keyword-only *strict* flag
179+
like :func:`zip` to check that all the iterables are of equal length.
180+
(Contributed by Wannes Boeykens in :gh:`119793`.)
181+
178182
* Incorrect usage of :keyword:`await` and asynchronous comprehensions
179183
is now detected even if the code is optimized away by the :option:`-O`
180184
command-line option. For example, ``python -O -c 'assert await 1'``
@@ -576,6 +580,11 @@ asyncio
576580

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

583+
* Removed implicit creation of event loop by :func:`asyncio.get_event_loop`.
584+
It now raises a :exc:`RuntimeError` if there is no current event loop.
585+
(Contributed by Kumar Aditya in :gh:`126353`.)
586+
587+
579588
collections.abc
580589
---------------
581590

Lib/asyncio/events.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,6 @@ class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):
668668

669669
class _Local(threading.local):
670670
_loop = None
671-
_set_called = False
672671

673672
def __init__(self):
674673
self._local = self._Local()
@@ -678,28 +677,6 @@ def get_event_loop(self):
678677
679678
Returns an instance of EventLoop or raises an exception.
680679
"""
681-
if (self._local._loop is None and
682-
not self._local._set_called and
683-
threading.current_thread() is threading.main_thread()):
684-
stacklevel = 2
685-
try:
686-
f = sys._getframe(1)
687-
except AttributeError:
688-
pass
689-
else:
690-
# Move up the call stack so that the warning is attached
691-
# to the line outside asyncio itself.
692-
while f:
693-
module = f.f_globals.get('__name__')
694-
if not (module == 'asyncio' or module.startswith('asyncio.')):
695-
break
696-
f = f.f_back
697-
stacklevel += 1
698-
import warnings
699-
warnings.warn('There is no current event loop',
700-
DeprecationWarning, stacklevel=stacklevel)
701-
self.set_event_loop(self.new_event_loop())
702-
703680
if self._local._loop is None:
704681
raise RuntimeError('There is no current event loop in thread %r.'
705682
% threading.current_thread().name)
@@ -708,7 +685,6 @@ def get_event_loop(self):
708685

709686
def set_event_loop(self, loop):
710687
"""Set the event loop."""
711-
self._local._set_called = True
712688
if loop is not None and not isinstance(loop, AbstractEventLoop):
713689
raise TypeError(f"loop must be an instance of AbstractEventLoop or None, not '{type(loop).__name__}'")
714690
self._local._loop = loop

Lib/getopt.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,8 @@
3434
__all__ = ["GetoptError","error","getopt","gnu_getopt"]
3535

3636
import os
37-
try:
38-
from gettext import gettext as _
39-
except ImportError:
40-
# Bootstrapping Python: gettext's dependencies not built yet
41-
def _(s): return s
37+
from gettext import gettext as _
38+
4239

4340
class GetoptError(Exception):
4441
opt = ''

0 commit comments

Comments
 (0)