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 2633b9af81c5b9..b7df689a8a674f 100644 --- a/Objects/genericaliasobject.c +++ b/Objects/genericaliasobject.c @@ -303,6 +303,7 @@ subs_tvars(PyObject *obj, PyObject *params, PyTuple_GET_SIZE(arg)); if (j < 0) { Py_DECREF(subparams); + /* tuple_extend() clears subargs on failure. */ assert(subargs == NULL); return NULL; }