Skip to content

Commit 7c4185d

Browse files
authored
bpo-39481: PEP 585 for enumerate, AsyncGeneratorType, mmap (GH-19421)
1 parent 2fa67df commit 7c4185d

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

Lib/test/test_genericalias.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
)
88
from collections.abc import *
99
from contextlib import AbstractContextManager, AbstractAsyncContextManager
10+
from mmap import mmap
1011
from ipaddress import IPv4Network, IPv4Interface, IPv6Network, IPv6Interface
1112
from itertools import chain
1213
from os import DirEntry
1314
from re import Pattern, Match
14-
from types import GenericAlias, MappingProxyType
15+
from types import GenericAlias, MappingProxyType, AsyncGeneratorType
1516
import typing
1617

1718
from typing import TypeVar
@@ -21,7 +22,8 @@ class BaseTest(unittest.TestCase):
2122
"""Test basics."""
2223

2324
def test_subscriptable(self):
24-
for t in (type, tuple, list, dict, set, frozenset,
25+
for t in (type, tuple, list, dict, set, frozenset, enumerate,
26+
mmap,
2527
defaultdict, deque,
2628
OrderedDict, Counter, UserDict, UserList,
2729
Pattern, Match,
@@ -37,10 +39,9 @@ def test_subscriptable(self):
3739
Mapping, MutableMapping, MappingView,
3840
KeysView, ItemsView, ValuesView,
3941
Sequence, MutableSequence,
40-
MappingProxyType,
42+
MappingProxyType, AsyncGeneratorType,
4143
DirEntry,
4244
IPv4Network, IPv4Interface, IPv6Network, IPv6Interface,
43-
MappingProxyType, DirEntry,
4445
chain,
4546
):
4647
tname = t.__name__

Modules/mmapmodule.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,8 @@ static struct PyMethodDef mmap_object_methods[] = {
816816
#ifdef MS_WINDOWS
817817
{"__sizeof__", (PyCFunction) mmap__sizeof__method, METH_NOARGS},
818818
#endif
819+
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS,
820+
PyDoc_STR("See PEP 585")},
819821
{NULL, NULL} /* sentinel */
820822
};
821823

Objects/enumobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
201201

202202
static PyMethodDef enum_methods[] = {
203203
{"__reduce__", (PyCFunction)enum_reduce, METH_NOARGS, reduce_doc},
204+
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
205+
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
204206
{NULL, NULL} /* sentinel */
205207
};
206208

Objects/genobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,8 @@ static PyMethodDef async_gen_methods[] = {
13461346
{"asend", (PyCFunction)async_gen_asend, METH_O, async_asend_doc},
13471347
{"athrow",(PyCFunction)async_gen_athrow, METH_VARARGS, async_athrow_doc},
13481348
{"aclose", (PyCFunction)async_gen_aclose, METH_NOARGS, async_aclose_doc},
1349+
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
1350+
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
13491351
{NULL, NULL} /* Sentinel */
13501352
};
13511353

0 commit comments

Comments
 (0)