mirror of https://github.com/python/cpython
gh-110864: TypeVar constructor: Partially revert gh-110784, `constraints` cannot be `NULL` (#110922)
This commit is contained in:
parent
02d26c4bef
commit
6a4528d70c
|
@ -363,12 +363,7 @@ typevar_new_impl(PyTypeObject *type, PyObject *name, PyObject *constraints,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constraints != NULL) {
|
assert(PyTuple_CheckExact(constraints));
|
||||||
if (!PyTuple_CheckExact(constraints)) {
|
|
||||||
PyErr_SetString(PyExc_TypeError,
|
|
||||||
"constraints must be a tuple");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
Py_ssize_t n_constraints = PyTuple_GET_SIZE(constraints);
|
Py_ssize_t n_constraints = PyTuple_GET_SIZE(constraints);
|
||||||
if (n_constraints == 1) {
|
if (n_constraints == 1) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
@ -383,7 +378,6 @@ typevar_new_impl(PyTypeObject *type, PyObject *name, PyObject *constraints,
|
||||||
Py_XDECREF(bound);
|
Py_XDECREF(bound);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
PyObject *module = caller();
|
PyObject *module = caller();
|
||||||
if (module == NULL) {
|
if (module == NULL) {
|
||||||
Py_XDECREF(bound);
|
Py_XDECREF(bound);
|
||||||
|
|
Loading…
Reference in New Issue