Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion Lib/test/test_genericalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
from tkinter import Event
except ImportError:
Event = None
from string.templatelib import Template, Interpolation

from typing import TypeVar
T = TypeVar('T')
Expand Down Expand Up @@ -139,7 +140,10 @@ class BaseTest(unittest.TestCase):
DictReader, DictWriter,
array,
staticmethod,
classmethod]
classmethod,
Template,
Interpolation,
]
if ctypes is not None:
generic_types.extend((ctypes.Array, ctypes.LibraryLoader, ctypes.py_object))
if ValueProxy is not None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Make :class:`string.templatelib.Template` and
:class:`string.templatelib.Interpolation` generic.
2 changes: 2 additions & 0 deletions Objects/interpolationobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ interpolation_reduce(PyObject *op, PyObject *Py_UNUSED(dummy))
static PyMethodDef interpolation_methods[] = {
{"__reduce__", interpolation_reduce, METH_NOARGS,
PyDoc_STR("__reduce__() -> (cls, state)")},
{"__class_getitem__", Py_GenericAlias,
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
{NULL, NULL},
};

Expand Down
2 changes: 2 additions & 0 deletions Objects/templateobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ template_reduce(PyObject *op, PyObject *Py_UNUSED(dummy))

static PyMethodDef template_methods[] = {
{"__reduce__", template_reduce, METH_NOARGS, NULL},
{"__class_getitem__", Py_GenericAlias,
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
{NULL, NULL},
};

Expand Down
Loading