https://github.com/python/cpython/commit/ea4cc585cd12ed73e5fe9978f943ceff5bb5cd51
commit: ea4cc585cd12ed73e5fe9978f943ceff5bb5cd51
branch: main
author: Petr Viktorin <[email protected]>
committer: encukou <[email protected]>
date: 2025-10-16T11:04:04Z
summary:
gh-139817: Fix refleak in TypeAliasType(qualname=non_string) (GH-140197)
files:
M Objects/typevarobject.c
diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c
index 8a3a1e9834583a..75a69d4bc3e019 100644
--- a/Objects/typevarobject.c
+++ b/Objects/typevarobject.c
@@ -2123,11 +2123,6 @@ typealias_new_impl(PyTypeObject *type, PyObject *name,
PyObject *value,
return NULL;
}
- PyObject *module = caller();
- if (module == NULL) {
- return NULL;
- }
-
if (qualname == NULL || qualname == Py_None) {
// If qualname was not set directly, we use name instead.
qualname = name;
@@ -2138,6 +2133,11 @@ typealias_new_impl(PyTypeObject *type, PyObject *name,
PyObject *value,
}
}
+ PyObject *module = caller();
+ if (module == NULL) {
+ return NULL;
+ }
+
PyObject *ta = (PyObject *)typealias_alloc(
name, qualname, checked_params, NULL, value, module);
Py_DECREF(module);
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]