Skip to content

Commit 02c6d47

Browse files
authored
Merge branch 'main' into fix-for-stmt-docs
2 parents 3795065 + c3a1da5 commit 02c6d47

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

Lib/test/test_genericalias.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
from tkinter import Event
6262
except ImportError:
6363
Event = None
64+
from string.templatelib import Template, Interpolation
6465

6566
from typing import TypeVar
6667
T = TypeVar('T')
@@ -139,7 +140,10 @@ class BaseTest(unittest.TestCase):
139140
DictReader, DictWriter,
140141
array,
141142
staticmethod,
142-
classmethod]
143+
classmethod,
144+
Template,
145+
Interpolation,
146+
]
143147
if ctypes is not None:
144148
generic_types.extend((ctypes.Array, ctypes.LibraryLoader, ctypes.py_object))
145149
if ValueProxy is not None:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Make :class:`!string.templatelib.Template` and
2+
:class:`!string.templatelib.Interpolation` generic.

Objects/interpolationobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ interpolation_reduce(PyObject *op, PyObject *Py_UNUSED(dummy))
137137
static PyMethodDef interpolation_methods[] = {
138138
{"__reduce__", interpolation_reduce, METH_NOARGS,
139139
PyDoc_STR("__reduce__() -> (cls, state)")},
140+
{"__class_getitem__", Py_GenericAlias,
141+
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
140142
{NULL, NULL},
141143
};
142144

Objects/templateobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ template_reduce(PyObject *op, PyObject *Py_UNUSED(dummy))
444444

445445
static PyMethodDef template_methods[] = {
446446
{"__reduce__", template_reduce, METH_NOARGS, NULL},
447+
{"__class_getitem__", Py_GenericAlias,
448+
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
447449
{NULL, NULL},
448450
};
449451

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy