Skip to content

bpo-39481: Make enumerate, AsyncGeneratorType, mmap generic #19421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Lib/test/test_genericalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
)
from collections.abc import *
from contextlib import AbstractContextManager, AbstractAsyncContextManager
from mmap import mmap
from ipaddress import IPv4Network, IPv4Interface, IPv6Network, IPv6Interface
from itertools import chain
from os import DirEntry
from re import Pattern, Match
from types import GenericAlias, MappingProxyType
from types import GenericAlias, MappingProxyType, AsyncGeneratorType
import typing

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

def test_subscriptable(self):
for t in (type, tuple, list, dict, set, frozenset,
for t in (type, tuple, list, dict, set, frozenset, enumerate,
mmap,
defaultdict, deque,
OrderedDict, Counter, UserDict, UserList,
Pattern, Match,
Expand All @@ -37,10 +39,9 @@ def test_subscriptable(self):
Mapping, MutableMapping, MappingView,
KeysView, ItemsView, ValuesView,
Sequence, MutableSequence,
MappingProxyType,
MappingProxyType, AsyncGeneratorType,
DirEntry,
IPv4Network, IPv4Interface, IPv6Network, IPv6Interface,
MappingProxyType, DirEntry,
chain,
):
tname = t.__name__
Expand Down
2 changes: 2 additions & 0 deletions Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,8 @@ static struct PyMethodDef mmap_object_methods[] = {
#ifdef MS_WINDOWS
{"__sizeof__", (PyCFunction) mmap__sizeof__method, METH_NOARGS},
#endif
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS,
PyDoc_STR("See PEP 585")},
{NULL, NULL} /* sentinel */
};

Expand Down
2 changes: 2 additions & 0 deletions Objects/enumobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");

static PyMethodDef enum_methods[] = {
{"__reduce__", (PyCFunction)enum_reduce, METH_NOARGS, reduce_doc},
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
{NULL, NULL} /* sentinel */
};

Expand Down
2 changes: 2 additions & 0 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,8 @@ static PyMethodDef async_gen_methods[] = {
{"asend", (PyCFunction)async_gen_asend, METH_O, async_asend_doc},
{"athrow",(PyCFunction)async_gen_athrow, METH_VARARGS, async_athrow_doc},
{"aclose", (PyCFunction)async_gen_aclose, METH_NOARGS, async_aclose_doc},
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
{NULL, NULL} /* Sentinel */
};

Expand Down