Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f2a4b10

Browse filesBrowse files
[3.14] gh-133970: Make PEP750 types generic (GH-133976) (#134029)
gh-133970: Make PEP750 types generic (GH-133976) (cherry picked from commit c3a1da5) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent b6299e8 commit f2a4b10
Copy full SHA for f2a4b10

File tree

4 files changed

+11
-1
lines changed
Filter options

4 files changed

+11
-1
lines changed

‎Lib/test/test_genericalias.py

Copy file name to clipboardExpand all lines: Lib/test/test_genericalias.py
+5-1Lines 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:
+2Lines 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

Copy file name to clipboardExpand all lines: Objects/interpolationobject.c
+2Lines 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

Copy file name to clipboardExpand all lines: Objects/templateobject.c
+2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.