8000 Merge remote-tracking branch 'upstream/main' into cpython-drop-gil · python/cpython@43f64d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43f64d7

Browse files
committed
Merge remote-tracking branch 'upstream/main' into cpython-drop-gil
2 parents d28bf13 + 1b1db2f commit 43f64d7

Some content is hidden

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

49 files changed

+283
-1689
lines changed

Doc/library/collections.abc.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ ABC Inherits from Abstract Methods Mi
141141
``__len__``,
142142
``insert``
143143

144-
:class:`ByteString` :class:`Sequence` ``__getitem__``, Inherited :class:`Sequence` methods
145-
``__len__``
146-
147144
:class:`Set` :class:`Collection` ``__contains__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``,
148145
``__iter__``, ``__gt__``, ``__ge__``, ``__and__``, ``__or__``,
149146
``__len__`` ``__sub__``, ``__xor__``, and ``isdisjoint``
@@ -257,7 +254,6 @@ Collections Abstract Base Classes -- Detailed Descriptions
257254

258255
.. class:: Sequence
259256
MutableSequence
260-
ByteString
261257

262258
ABCs for read-only and mutable :term:`sequences <sequence>`.
263259

@@ -274,12 +270,6 @@ Collections Abstract Base Classes -- Detailed Descriptions
274270
The index() method added support for *stop* and *start*
275271
arguments.
276272

277-
.. deprecated-removed:: 3.12 3.14
278-
The :class:`ByteString` ABC has been deprecated.
279-
For use in typing, prefer a union, like ``bytes | bytearray``, or
280-
:class:`collections.abc.Buffer`.
281-
For use as an ABC, prefer :class:`Sequence` or :class:`collections.abc.Buffer`.
282-
283273
.. class:: Set
284274
MutableSet
285275

Doc/library/constants.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ A small number of constants live in the built-in namespace. They are:
5353
See :exc:`NotImplementedError` for details on when to use it.
5454

5555
.. versionchanged:: 3.9
56-
Evaluating :data:`!NotImplemented` in a boolean context is deprecated. While
57-
it currently evaluates as true, it will emit a :exc:`DeprecationWarning`.
58-
It will raise a :exc:`TypeError` in a future version of Python.
56+
Evaluating :data:`!NotImplemented` in a boolean context was deprecated.
5957

6058
.. versionchanged:: 3.14
6159
Evaluating :data:`!NotImplemented` in a boolean context now raises a :exc:`TypeError`.
60+
It previously evaluated to :const:`True` and emitted a :exc:`DeprecationWarning`
61+
since Python 3.9.
6262

6363

6464
.. index:: single: ...; ellipsis literal

Doc/library/email.utils.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ module:
1717
arguments, return current time. Otherwise *dt* argument should be a
1818
:class:`~datetime.datetime` instance, and it is converted to the local time
1919
zone according to the system time zone database. If *dt* is naive (that
20-
is, ``dt.tzinfo`` is ``None``), it is assumed to be in local time. The
21-
*isdst* parameter is ignored.
20+
is, ``dt.tzinfo`` is ``None``), it is assumed to be in local time.
2221

2322
.. versionadded:: 3.3
2423

Doc/library/stdtypes.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5061,7 +5061,6 @@ list is non-exhaustive.
50615061
* :class:`collections.abc.MutableMapping`
50625062
* :class:`collections.abc.Sequence`
50635063
* :class:`collections.abc.MutableSequence`
5064-
* :class:`collections.abc.ByteString`
50655064
* :class:`collections.abc.MappingView`
50665065
* :class:`collections.abc.KeysView`
50675066
* :class:`collections.abc.ItemsView`

Doc/library/typing.rst

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3502,14 +3502,6 @@ Aliases to container ABCs in :mod:`collections.abc`
35023502
:class:`collections.abc.Set` now supports subscripting (``[]``).
35033503
See :pep:`585` and :ref:`types-genericalias`.
35043504

3505-
.. class:: ByteString(Sequence[int])
3506-
3507-
This type represents the types :class:`bytes`, :class:`bytearray`,
3508-
and :class:`memoryview` of byte sequences.
3509-
3510-
.. deprecated-removed:: 3.9 3.14
3511-
Prefer :class:`collections.abc.Buffer`, or a union like ``bytes | bytearray | memoryview``.
3512-
35133505
.. class:: Collection(Sized, Iterable[T_co], Container[T_co])
35143506

35153507
Deprecated alias to :class:`collections.abc.Collection`.
@@ -3875,10 +3867,6 @@ convenience. This is subject to change, and not all deprecations are listed.
38753867
- 3.9
38763868
- Undecided (see :ref:`deprecated-aliases` for more information)
38773869
- :pep:`585`
3878-
* - :class:`typing.ByteString`
3879-
- 3.9
3880-
- 3.14
3881-
- :gh:`91896`
38823870
* - :data:`typing.Text`
38833871
- 3.11
38843872
- Undecided

Doc/reference/datamodel.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ See
170170
for more details.
171171

172172
.. versionchanged:: 3.9
173-
Evaluating :data:`NotImplemented` in a boolean context is deprecated. While
174-
it currently evaluates as true, it will emit a :exc:`DeprecationWarning`.
175-
It will raise a :exc:`TypeError` in a future version of Python.
173+
Evaluating :data:`NotImplemented` in a boolean context was deprecated.
176174

177175
.. versionchanged:: 3.14
178176
Evaluating :data:`NotImplemented` in a boolean context now raises a :exc:`TypeError`.
177+
It previously evaluated to :const:`True` and emitted a :exc:`DeprecationWarning`
178+
since Python 3.9.
179179

180180

181181
Ellipsis

Doc/whatsnew/3.12.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ Deprecated
11831183
replaced by :data:`calendar.JANUARY` and :data:`calendar.FEBRUARY`.
11841184
(Contributed by Prince Roshan in :gh:`103636`.)
11851185

1186-
* :mod:`collections.abc`: Deprecated :class:`collections.abc.ByteString`.
1186+
* :mod:`collections.abc`: Deprecated :class:`!collections.abc.ByteString`.
11871187
Prefer :class:`Sequence` or :class:`collections.abc.Buffer`.
11881188
For use in typing, prefer a union, like ``bytes | bytearray``, or :class:`collections.abc.Buffer`.
11891189
(Contributed by Shantanu Jain in :gh:`91896`.)
@@ -1293,7 +1293,7 @@ Deprecated
12931293
:class:`collections.abc.Hashable` and :class:`collections.abc.Sized` respectively, are
12941294
deprecated. (:gh:`94309`.)
12951295

1296-
* :class:`typing.ByteString`, deprecated since Python 3.9, now causes a
1296+
* :class:`!typing.ByteString`, deprecated since Python 3.9, now causes a
12971297
:exc:`DeprecationWarning` to be emitted when it is used.
12981298
(Contributed by Alex Waygood in :gh:`91896`.)
12991299

Doc/whatsnew/3.13.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ Pending Removal in Python 3.14
15731573
Use :class:`ast.Constant` instead.
15741574
(Contributed by Serhiy Storchaka in :gh:`90953`.)
15751575

1576-
* :mod:`collections.abc`: Deprecated :class:`~collections.abc.ByteString`.
1576+
* :mod:`collections.abc`: Deprecated :class:`!collections.abc.ByteString`.
15771577
Prefer :class:`!Sequence` or :class:`~collections.abc.Buffer`.
15781578
For use in typing, prefer a union, like ``bytes | bytearray``,
15791579
or :class:`collections.abc.Buffer`.
@@ -1647,7 +1647,7 @@ Pending Removal in Python 3.14
16471647
May be removed in 3.14.
16481648
(Contributed by Nikita Sobolev in :gh:`101866`.)
16491649

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

16531653
* :mod:`urllib`:

Doc/whatsnew/3.14.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,34 @@ Deprecated
101101
Removed
102102
=======
103103

104+
argparse
105+
--------
106+
107+
* The *type*, *choices*, and *metavar* parameters
108+
of :class:`!argparse.BooleanOptionalAction` are removed.
109+
They were deprecated since 3.12.
110+
111+
email
112+
-----
113+
114+
* The *isdst* parameter has been removed from :func:`email.utils.localtime`.
115+
(Contributed by Hugo van Kemenade in :gh:`118798`.)
116+
117+
Others
118+
------
119+
104120
* Using :data:`NotImplemented` in a boolean context will now raise a :exc:`TypeError`.
105121
It had previously raised a :exc:`DeprecationWarning` since Python 3.9. (Contributed
106122
by Jelle Zijlstra in :gh:`118767`.)
107123

124+
* :class:`!typing.ByteString` and :class:`!collections.abc.ByteString`
125+
are removed. They had previously raised a :exc:`DeprecationWarning`
126+
since Python 3.12.
127+
128+
* :mod:`itertools` support for copy, deepcopy, and pickle operations.
129+
These had previously raised a :exc:`DeprecationWarning` since Python 3.12.
130+
(Contributed by Raymond Hettinger in :gh:`101588`.)
131+
108132

109133
Porting to Python 3.14
110134
======================

Include/internal/mimalloc/mimalloc/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ terms of the MIT license. A copy of the license can be found in the file
1414
// functions and macros.
1515
// --------------------------------------------------------------------------
1616

17-
#include "mimalloc/types.h"
18-
#include "mimalloc/track.h"
17+
#include "types.h"
18+
#include "track.h"
1919

2020
#if (MI_DEBUG>0)
2121
#define mi_trace_message(...) _mi_trace_message(__VA_ARGS__)

Include/internal/mimalloc/mimalloc/types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ terms of the MIT license. A copy of the license can be found in the file
2121

2222
#include <stddef.h> // ptrdiff_t
2323
#include <stdint.h> // uintptr_t, uint16_t, etc
24-
#include "mimalloc/atomic.h" // _Atomic
24+
#include "atomic.h" // _Atomic
2525

2626
#ifdef _MSC_VER
2727
#pragma warning(disable:4214) // bitfield is not int

Include/internal/pycore_mimalloc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ typedef enum {
3636
# define MI_TSAN 1
3737
#endif
3838

39-
#include "mimalloc.h"
40-
#include "mimalloc/types.h"
41-
#include "mimalloc/internal.h"
39+
#include "mimalloc/mimalloc.h"
40+
#include "mimalloc/mimalloc/types.h"
41+
#include "mimalloc/mimalloc/internal.h"
4242
#endif
4343

4444
#ifdef Py_GIL_DISABLED

Lib/_collections_abc.py

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _f(): pass
4949
"Mapping", "MutableMapping",
5050
"MappingView", "KeysView", "ItemsView", "ValuesView",
5151
"Sequence", "MutableSequence",
52-
"ByteString", "Buffer",
52+
"Buffer",
5353
]
5454

5555
# This module has been renamed from collections.abc to _collections_abc to
@@ -1068,40 +1068,10 @@ def count(self, value):
10681068

10691069
Sequence.register(tuple)
10701070
Sequence.register(str)
1071+
Sequence.register(bytes)
10711072
Sequence.register(range)
10721073
Sequence.register(memoryview)
10731074

1074-
class _DeprecateByteStringMeta(ABCMeta):
1075-
def __new__(cls, name, bases, namespace, **kwargs):
1076-
if name != "ByteString":
1077-
import warnings
1078-
1079-
warnings._deprecated(
1080-
&q 10000 uot;collections.abc.ByteString",
1081-
remove=(3, 14),
1082-
)
1083-
return super().__new__(cls, name, bases, namespace, **kwargs)
1084-
1085-
def __instancecheck__(cls, instance):
1086-
import warnings
1087-
1088-
warnings._deprecated(
1089-
"collections.abc.ByteString",
1090-
remove=(3, 14),
1091-
)
1092-
return super().__instancecheck__(instance)
1093-
1094-
class ByteString(Sequence, metaclass=_DeprecateByteStringMeta):
1095-
"""This unifies bytes and bytearray.
1096-
1097-
XXX Should add all their methods.
1098-
"""
1099-
1100-
__slots__ = ()
1101-
1102-
ByteString.register(bytes)
1103-
ByteString.register(bytearray)
1104-
11051075

11061076
class MutableSequence(Sequence):
11071077
"""All the operations on a read-write sequence.
@@ -1170,4 +1140,4 @@ def __iadd__(self, values):
11701140

11711141

11721142
MutableSequence.register(list)
1173-
MutableSequence.register(bytearray) # Multiply inheriting, see ByteString
1143+
MutableSequence.register(bytearray)

Lib/argparse.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -831,19 +831,13 @@ def __call__(self, parser, namespace, values, option_string=None):
831831
raise NotImplementedError(_('.__call__() not defined'))
832832

833833

834-
# FIXME: remove together with `BooleanOptionalAction` deprecated arguments.
835-
_deprecated_default = object()
836-
837834
class BooleanOptionalAction(Action):
838835
def __init__(self,
839836
option_strings,
840837
dest,
841838
default=None,
842-
type=_deprecated_default,
843-
choices=_deprecated_default,
844839
required=False,
845840
help=None,
846-
metavar=_deprecated_default,
847841
deprecated=False):
848842

849843
_option_strings = []
@@ -854,35 +848,13 @@ def __init__(self,
854848
option_string = '--no-' + option_string[2:]
855849
_option_strings.append(option_string)
856850

857-
# We need `_deprecated` special value to ban explicit arguments that
858-
# match default value. Like:
859-
# parser.add_argument('-f', action=BooleanOptionalAction, type=int)
860-
for field_name in ('type', 'choices', 'metavar'):
861-
if locals()[field_name] is not _deprecated_default:
862-
import warnings
863-
warnings._deprecated(
864-
field_name,
865-
"{name!r} is deprecated as of Python 3.12 and will be "
866-
"removed in Python {remove}.",
867-
remove=(3, 14))
868-
869-
if type is _deprecated_default:
870-
type = None
871-
if choices is _deprecated_default:
872-
choices = None
873-
if metavar is _deprecated_default:
874-
metavar = None
875-
876851
super().__init__(
877852
option_strings=_option_strings,
878853
dest=dest,
879854
nargs=0,
880855
default=default,
881-
type=type,
882-
choices=choices,
883856
required=required,
884857
help=help,
885-
metavar=metavar,
886858
deprecated=deprecated)
887859

888860

Lib/asyncio/__main__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def run(self):
108108
try:
109109
import readline # NoQA
110110
except ImportError:
111-
pass
111+
readline = None
112112

113113
interactive_hook = getattr(sys, "__interactivehook__", None)
114114

@@ -122,8 +122,9 @@ def run(self):
122122
except:
123123
pass
124124
else:
125-
completer = rlcompleter.Completer(console.locals)
126-
readline.set_completer(completer.complete)
125+
if readline is not None:
126+
completer = rlcompleter.Completer(console.locals)
127+
readline.set_completer(completer.complete)
127128

128129
repl_thread = REPLThread()
129130
repl_thread.daemon = True

Lib/dataclasses.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,10 +1199,17 @@ def _dataclass_setstate(self, state):
11991199

12001200
def _get_slots(cls):
12011201
match cls.__dict__.get('__slots__'):
1202-
# A class which does not define __slots__ at all is equivalent
1203-
# to a class defining __slots__ = ('__dict__', '__weakref__')
1202+
# `__dictoffset__` and `__weakrefoffset__` can tell us whether
1203+
# the base type has dict/weakref slots, in a way that works correctly
1204+
# for both Python classes and C extension types. Extension types
1205+
# don't use `__slots__` for slot creation
12041206
case None:
1205-
yield from ('__dict__', '__weakref__')
1207+
slots = []
1208+
if getattr(cls, '__weakrefoffset__', -1) != 0:
1209+
slots.append('__weakref__')
1210+
if getattr(cls, '__dictrefoffset__', -1) != 0:
1211+
slots.append('__dict__')
1212+
yield from slots
12061213
case str(slot):
12071214
yield slot
12081215
# Slots may be any iterable, but we cannot handle an iterator

Lib/email/utils.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -466,23 +466,15 @@ def collapse_rfc2231_value(value, errors='replace',
466466
# better than not having it.
467467
#
468468

469-
def localtime(dt=None, isdst=None):
469+
def localtime(dt=None):
470470
"""Return local time as an aware datetime object.
471471
472472
If called without arguments, return current time. Otherwise *dt*
473473
argument should be a datetime instance, and it is converted to the
474474
local time zone according to the system time zone database. If *dt* is
475475
naive (that is, dt.tzinfo is None), it is assumed to be in local time.
476-
The isdst parameter is ignored.
477476
478477
"""
479-
if isdst is not None:
480-
import warnings
481-
warnings._deprecated(
482-
"The 'isdst' parameter to 'localtime'",
483-
message='{name} is deprecated and slated for removal in Python {remove}',
484-
remove=(3, 14),
485-
)
486478
if dt is None:
487479
dt = datetime.datetime.now()
488480
return dt.astimezone()

Lib/test/libregrtest/refleak.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
211211
zipimport._zip_directory_cache.update(zdc)
212212

213213
# Clear ABC registries, restoring previously saved ABC registries.
214-
# ignore deprecation warning for collections.abc.ByteString
215214
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
216215
abs_classes = filter(isabstract, abs_classes)
217216
for abc in abs_classes:

0 commit comments

Comments
 (0)
0