PyObject *
_Py_make_parameters(PyObject *args)
{
+ if (Py_EnterRecursiveCall(" in __parameter__ calculation")) {
+ return NULL;
+ }
+
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
Py_ssize_t len = nargs;
PyObject *parameters = PyTuple_New(len);
- if (parameters == NULL)
- return NULL;
+ if (parameters == NULL) {
+ goto cleanup;
+ }
Py_ssize_t iparam = 0;
for (Py_ssize_t iarg = 0; iarg < nargs; iarg++) {
PyObject *t = PyTuple_GET_ITEM(args, iarg);
}
int rc = PyObject_HasAttrWithError(t, &_Py_ID(__typing_subst__));
if (rc < 0) {
- Py_DECREF(parameters);
- return NULL;
+ goto error;
}
if (rc) {
iparam += tuple_add(parameters, iparam, t);
PyObject *subparams;
if (PyObject_GetOptionalAttr(t, &_Py_ID(__parameters__),
&subparams) < 0) {
- Py_DECREF(parameters);
- return NULL;
+ goto error;
}
if (subparams && PyTuple_Check(subparams)) {
Py_ssize_t len2 = PyTuple_GET_SIZE(subparams);
len += needed;
if (_PyTuple_Resize(¶meters, len) < 0) {
Py_DECREF(subparams);
- return NULL;
+ goto cleanup;
}
}
for (Py_ssize_t j = 0; j < len2; j++) {
}
if (iparam < len) {
if (_PyTuple_Resize(¶meters, iparam) < 0) {
- Py_XDECREF(parameters);
- return NULL;
+ goto error;
}
}
+ Py_LeaveRecursiveCall();
return parameters;
+
+error:
+ Py_XDECREF(parameters);
+cleanup:
+ Py_LeaveRecursiveCall();
+ return NULL;
}
/* If obj is a generic alias, substitute type variables params