@@ -364,24 +364,26 @@ typevar_new_impl(PyTypeObject *type, PyObject *name, PyObject *constraints,
364364 }
365365 }
366366
367- if (!PyTuple_CheckExact (constraints )) {
368- PyErr_SetString (PyExc_TypeError ,
369- "constraints must be a tuple" );
370- return NULL ;
371- }
372- Py_ssize_t n_constraints = PyTuple_GET_SIZE (constraints );
373- if (n_constraints == 1 ) {
374- PyErr_SetString (PyExc_TypeError ,
375- "A single constraint is not allowed" );
376- Py_XDECREF (bound );
377- return NULL ;
378- } else if (n_constraints == 0 ) {
379- constraints = NULL ;
380- } else if (bound != NULL ) {
381- PyErr_SetString (PyExc_TypeError ,
382- "Constraints cannot be combined with bound=..." );
383- Py_XDECREF (bound );
384- return NULL ;
367+ if (constraints != NULL ) {
368+ if (!PyTuple_CheckExact (constraints )) {
369+ PyErr_SetString (PyExc_TypeError ,
370+ "constraints must be a tuple" );
371+ return NULL ;
372+ }
373+ Py_ssize_t n_constraints = PyTuple_GET_SIZE (constraints );
374+ if (n_constraints == 1 ) {
375+ PyErr_SetString (PyExc_TypeError ,
376+ "A single constraint is not allowed" );
377+ Py_XDECREF (bound );
378+ return NULL ;
379+ } else if (n_constraints == 0 ) {
380+ constraints = NULL ;
381+ } else if (bound != NULL ) {
382+ PyErr_SetString (PyExc_TypeError ,
383+ "Constraints cannot be combined with bound=..." );
384+ Py_XDECREF (bound );
385+ return NULL ;
386+ }
385387 }
386388 PyObject * module = caller ();
387389 if (module == NULL ) {
0 commit comments