Skip to content

Commit b5f4f5c

Browse files
committed
pythongh-110784: Partially revert pythongh-110784, constraints cannot be NULL
1 parent c2192a2 commit b5f4f5c

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

Objects/typevarobject.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -364,26 +364,24 @@ typevar_new_impl(PyTypeObject *type, PyObject *name, PyObject *constraints,
364364
}
365365
}
366366

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-
}
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;
387385
}
388386
PyObject *module = caller();
389387
if (module == NULL) {

0 commit comments

Comments
 (0)