Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-115999-thread-local-bytecode
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Nov 4, 2024
2 parents 338f7e5 + eac41c5 commit bcd1bb2
Show file tree
Hide file tree
Showing 38 changed files with 864 additions and 287 deletions.
7 changes: 0 additions & 7 deletions Doc/deprecations/pending-removal-in-3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +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`.

* :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,
but it only got a proper :exc:`DeprecationWarning` in 3.12.
May be removed in 3.14.
(Contributed by Nikita Sobolev in :gh:`101866`.)

* :mod:`typing`: :class:`!typing.ByteString`, deprecated since Python 3.9,
now causes a :exc:`DeprecationWarning` to be emitted when it is used.

Expand Down
9 changes: 9 additions & 0 deletions Doc/deprecations/pending-removal-in-3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ Pending removal in Python 3.15
but the C version allows any number of positional or keyword arguments,
ignoring every argument.

* :mod:`types`:

* :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,
but it only got a proper :exc:`DeprecationWarning` in 3.12.
May be removed in 3.15.
(Contributed by Nikita Sobolev in :gh:`101866`.)

* :mod:`typing`:

* The undocumented keyword argument syntax for creating
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
2 changes: 1 addition & 1 deletion Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ Special read-only attributes

.. deprecated:: 3.12
This attribute of code objects is deprecated, and may be removed in
Python 3.14.
Python 3.15.

* - .. attribute:: codeobject.co_stacksize
- The required stack size of the code object
Expand Down
4 changes: 2 additions & 2 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1327,8 +1327,8 @@ Deprecated

* Accessing :attr:`~codeobject.co_lnotab` on code objects was deprecated in
Python 3.10 via :pep:`626`,
but it only got a proper :exc:`DeprecationWarning` in 3.12,
therefore it will be removed in 3.14.
but it only got a proper :exc:`DeprecationWarning` in 3.12.
May be removed in 3.15.
(Contributed by Nikita Sobolev in :gh:`101866`.)

.. include:: ../deprecations/pending-removal-in-3.13.rst
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
3 changes: 3 additions & 0 deletions Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(strict_mode)
STRUCT_FOR_ID(string)
STRUCT_FOR_ID(sub_key)
STRUCT_FOR_ID(subcalls)
STRUCT_FOR_ID(symmetric_difference_update)
STRUCT_FOR_ID(tabsize)
STRUCT_FOR_ID(tag)
Expand All @@ -737,8 +738,10 @@ struct _Py_global_strings {
STRUCT_FOR_ID(threading)
STRUCT_FOR_ID(throw)
STRUCT_FOR_ID(timeout)
STRUCT_FOR_ID(timer)
STRUCT_FOR_ID(times)
STRUCT_FOR_ID(timetuple)
STRUCT_FOR_ID(timeunit)
STRUCT_FOR_ID(top)
STRUCT_FOR_ID(trace_callback)
STRUCT_FOR_ID(traceback)
Expand Down
3 changes: 3 additions & 0 deletions Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
Loading

0 comments on commit bcd1bb2

Please sign in to comment.