diff options
author | sobolevn <mail@sobolevn.me> | 2024-09-26 14:15:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-26 14:15:38 (GMT) |
commit | abe5f799e6ce1d177f79554f1b84d348b6141045 (patch) | |
tree | 20548f04e2a7fbd56ad8cb02fa95be5b8f19c06c /Objects | |
parent | cf2418076d7cf69a3bd4bf6be0e0001635a7ad4d (diff) | |
download | cpython-abe5f799e6ce1d177f79554f1b84d348b6141045.zip cpython-abe5f799e6ce1d177f79554f1b84d348b6141045.tar.gz cpython-abe5f799e6ce1d177f79554f1b84d348b6141045.tar.bz2 |
gh-124498: Fix `TypeAliasType` not to be generic, when `type_params=()` (#124499)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typevarobject.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Objects/typevarobject.c b/Objects/typevarobject.c index 09e9ab3..552c474 100644 --- a/Objects/typevarobject.c +++ b/Objects/typevarobject.c @@ -1915,7 +1915,16 @@ typealias_alloc(PyObject *name, PyObject *type_params, PyObject *compute_value, return NULL; } ta->name = Py_NewRef(name); - ta->type_params = Py_IsNone(type_params) ? NULL : Py_XNewRef(type_params); + if ( + type_params == NULL + || Py_IsNone(type_params) + || (PyTuple_Check(type_params) && PyTuple_GET_SIZE(type_params) == 0) + ) { + ta->type_params = NULL; + } + else { + ta->type_params = Py_NewRef(type_params); + } ta->compute_value = Py_XNewRef(compute_value); ta->value = Py_XNewRef(value); ta->module = Py_XNewRef(module); |