diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-08-01-19-17-56.gh-issue-155053.sxmlTO.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-01-19-17-56.gh-issue-155053.sxmlTO.rst new file mode 100644 index 00000000000000..d96566f8776574 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-08-01-19-17-56.gh-issue-155053.sxmlTO.rst @@ -0,0 +1,2 @@ +Fix a crash in :class:`types.GenericAlias` during substitution of a +``TypeVarTuple`` under allocation failure. diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c index 348c7dd6967a39..52adbb395cf6be 100644 --- a/Objects/genericaliasobject.c +++ b/Objects/genericaliasobject.c @@ -302,7 +302,8 @@ subs_tvars(PyObject *obj, PyObject *params, PyTuple_GET_SIZE(arg)); if (j < 0) { Py_DECREF(subparams); - Py_DECREF(subargs); + /* tuple_extend() clears subargs on failure. */ + assert(subargs == NULL); return NULL; } continue;