Skip to content

Commit 4445b5a

Browse files
committed
Improve error message.
Also fix incorrect DECREF.
1 parent 46b6fa3 commit 4445b5a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Objects/genericaliasobject.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,10 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
529529
Py_DECREF(newargs);
530530
Py_DECREF(item);
531531
Py_XDECREF(tuple_args);
532+
PyObject *original = PyTuple_GET_ITEM(args, iarg);
532533
PyErr_Format(PyExc_TypeError,
533-
"expected a tuple, not %T", arg);
534+
"expected __typing_subst__ of %T objects to return a tuple, not %T",
535+
original, arg);
534536
Py_DECREF(arg);
535537
return NULL;
536538
}
@@ -540,7 +542,7 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
540542
if (jarg < 0) {
541543
Py_DECREF(item);
542544
Py_XDECREF(tuple_args);
543-
Py_DECREF(newargs);
545+
/* newargs was stolen */
544546
return NULL;
545547
}
546548
}

0 commit comments

Comments
 (0)