From ed8e9dada8d750e14d1b2ef8643f119abce2c3b0 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 20 Oct 2026 10:39:09 -0700 Subject: [PATCH] [3.14] gh-159739: [typing] Handle generic alias construction errors (GH-159772) Backport the typevarobject.c fix; Python 3.14 does not decref subargs on the generic-alias substitution error path. (cherry picked from commit 07df106f7efa7e5e3f5fba4b4927eaba5bcd98d0) --- .../2026-10-19-20-38-17.gh-issue-159739.b62fc9.rst | 1 + Objects/typevarobject.c | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2026-10-19-20-38-17.gh-issue-159739.b62fc9.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-10-19-20-38-17.gh-issue-159739.b62fc9.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-19-20-38-17.gh-issue-159739.b62fc9.rst new file mode 100644 index 00000000000000..f61a0f76143570 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-10-19-20-38-17.gh-issue-159739.b62fc9.rst @@ -0,0 +1 @@ +Propagate errors during generic class construction. diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 3cbc471f465f54..628963b5770214 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -2271,6 +2271,9 @@ PyObject * _Py_subscript_generic(PyThreadState* unused, PyObject *params) { params = unpack_typevartuples(params); + if (params == NULL) { + return NULL; + } PyInterpreterState *interp = _PyInterpreterState_GET(); if (interp->cached_objects.generic_type == NULL) {