1- // TypeVar, TypeVarTuple, and ParamSpec
1+ // TypeVar, TypeVarTuple, ParamSpec, and TypeAlias
22#include "Python.h"
33#include "pycore_object.h" // _PyObject_GC_TRACK/UNTRACK, PyAnnotateFormat
44#include "pycore_typevarobject.h"
@@ -394,7 +394,7 @@ caller(void)
394394}
395395
396396static PyObject *
397- typevartuple_unpack (PyObject * tvt )
397+ unpack (PyObject * self )
398398{
399399 PyObject * typing = PyImport_ImportModule ("typing" );
400400 if (typing == NULL ) {
@@ -405,7 +405,7 @@ typevartuple_unpack(PyObject *tvt)
405405 Py_DECREF (typing );
406406 return NULL ;
407407 }
408- PyObject * unpacked = PyObject_GetItem (unpack , tvt );
408+ PyObject * unpacked = PyObject_GetItem (unpack , self );
409409 Py_DECREF (typing );
410410 Py_DECREF (unpack );
411411 return unpacked ;
@@ -440,7 +440,7 @@ unpack_typevartuples(PyObject *params)
440440 for (Py_ssize_t i = 0 ; i < n ; i ++ ) {
441441 PyObject * param = PyTuple_GET_ITEM (params , i );
442442 if (Py_IS_TYPE (param , tp )) {
443- PyObject * unpacked = typevartuple_unpack (param );
443+ PyObject * unpacked = unpack (param );
444444 if (unpacked == NULL ) {
445445 Py_DECREF (new_params );
446446 return NULL ;
@@ -1524,9 +1524,9 @@ typevartuple_dealloc(PyObject *self)
15241524}
15251525
15261526static PyObject *
1527- typevartuple_iter (PyObject * self )
1527+ unpack_iter (PyObject * self )
15281528{
1529- PyObject * unpacked = typevartuple_unpack (self );
1529+ PyObject * unpacked = unpack (self );
15301530 if (unpacked == NULL ) {
15311531 return NULL ;
15321532 }
@@ -1782,7 +1782,7 @@ PyType_Slot typevartuple_slots[] = {
17821782 {Py_tp_methods , typevartuple_methods },
17831783 {Py_tp_getset , typevartuple_getset },
17841784 {Py_tp_new , typevartuple },
1785- {Py_tp_iter , typevartuple_iter },
1785+ {Py_tp_iter , unpack_iter },
17861786 {Py_tp_repr , typevartuple_repr },
17871787 {Py_tp_dealloc , typevartuple_dealloc },
17881788 {Py_tp_alloc , PyType_GenericAlloc },
@@ -2158,6 +2158,7 @@ PyTypeObject _PyTypeAlias_Type = {
21582158 .tp_dealloc = typealias_dealloc ,
21592159 .tp_new = typealias_new ,
21602160 .tp_free = PyObject_GC_Del ,
2161+ .tp_iter = unpack_iter ,
21612162 .tp_traverse = typealias_traverse ,
21622163 .tp_clear = typealias_clear ,
21632164 .tp_repr = typealias_repr ,
0 commit comments