self.assertEqual(G2[[int, str], float], list[C])
self.assertEqual(G3[[int, str], float], list[C] | int)
+ def test_paramspec_bound(self):
+ P = ParamSpec('P', bound=[int, str])
+ self.assertEqual(P.__bound__, [int, str])
+ P2 = ParamSpec('P2', bound=(int, str))
+ self.assertEqual(P2.__bound__, (int, str))
+ obj = object()
+ P3 = ParamSpec('P3', bound=obj)
+ self.assertIs(P3.__bound__, obj)
+ P4 = ParamSpec('P4')
+ self.assertIs(P4.__bound__, None)
+
def test_paramspec_gets_copied(self):
# bpo-46581
P = ParamSpec('P')
PyErr_SetString(PyExc_ValueError, "Variance cannot be specified with infer_variance.");
return NULL;
}
- if (bound != NULL) {
- bound = type_check(bound, "Bound must be a type.");
- if (bound == NULL) {
- return NULL;
- }
- }
PyObject *module = caller();
if (module == NULL) {
- Py_XDECREF(bound);
return NULL;
}
PyObject *ps = (PyObject *)paramspec_alloc(
name, bound, default_value, covariant, contravariant, infer_variance, module);
- Py_XDECREF(bound);
Py_DECREF(module);
return ps;
}