[Python-checkins] Generic itertools.chain (GH-19417)

Ethan Smith webhook-mailer at python.org
Thu Apr 9 23:28:19 EDT 2020


https://github.com/python/cpython/commit/a8403d057d41a022d819fd8d6fbe2a666f72b6f5
commit: a8403d057d41a022d819fd8d6fbe2a666f72b6f5
branch: master
author: Ethan Smith <ethan at ethanhs.me>
committer: GitHub <noreply at github.com>
date: 2020-04-09T20:28:08-07:00
summary:

Generic itertools.chain (GH-19417)

files:
M Lib/test/test_genericalias.py
M Modules/itertoolsmodule.c

diff --git a/Lib/test/test_genericalias.py b/Lib/test/test_genericalias.py
index 9c5b23e5e5b0f..d8acdee2da3e2 100644
--- a/Lib/test/test_genericalias.py
+++ b/Lib/test/test_genericalias.py
@@ -7,6 +7,7 @@
 )
 from collections.abc import *
 from contextlib import AbstractContextManager, AbstractAsyncContextManager
+from itertools import chain
 from os import DirEntry
 from re import Pattern, Match
 from types import GenericAlias, MappingProxyType
@@ -35,7 +36,8 @@ def test_subscriptable(self):
                   Mapping, MutableMapping, MappingView,
                   KeysView, ItemsView, ValuesView,
                   Sequence, MutableSequence,
-                  MappingProxyType, DirEntry
+                  MappingProxyType, DirEntry,
+                  chain,
                   ):
             tname = t.__name__
             with self.subTest(f"Testing {tname}"):
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index e99c964ac1d79..4ebeb741b6b5c 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -2028,6 +2028,8 @@ static PyMethodDef chain_methods[] = {
      reduce_doc},
     {"__setstate__",    (PyCFunction)chain_setstate,    METH_O,
      setstate_doc},
+    {"__class_getitem__",    (PyCFunction)Py_GenericAlias,
+    METH_O|METH_CLASS,       PyDoc_STR("See PEP 585")},
     {NULL,              NULL}           /* sentinel */
 };
 



More information about the Python-checkins mailing list