from queue import Queue, SimpleQueue
from weakref import WeakSet, ReferenceType, ref
import typing
-from typing import Unpack
+from typing import TypeVar, Unpack
-from typing import TypeVar
T = TypeVar('T')
K = TypeVar('K')
V = TypeVar('V')
iter_x = iter(t)
del iter_x
+ def test_gh150146(self):
+ # It used to crash:
+ for container in [list, tuple]:
+ with self.subTest(container=container):
+ x = container[TypeVar("")]
+ with self.assertRaises(TypeError):
+ x[*typing.Mapping[..., ...]]
class TypeIterationTests(unittest.TestCase):
_UNITERABLE_TYPES = (list, tuple)
--- /dev/null
+Fix a crash on a complex type variable substitution.
+
+``from typing import TypeVar; memoryview[TypeVar("")][*typing.Mapping[...,
+...]]`` used to fail due to missing ``NULL`` check on ``_unpack_args`` C
+function call.
self);
}
item = _unpack_args(item);
+ if (item == NULL) {
+ return NULL;
+ }
for (Py_ssize_t i = 0; i < nparams; i++) {
PyObject *param = PyTuple_GET_ITEM(parameters, i);
PyObject *prepare, *tmp;