diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-01 08:01:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-01 08:01:28 (GMT) |
commit | 20c258c6928b878e0cb63f6b792e904e18f2242f (patch) | |
tree | 6b9e989d53110b2a6169d1f055c33b4833a35116 /Objects | |
parent | 217a31742544729a001dea9139cc272e64e33064 (diff) | |
download | cpython-20c258c6928b878e0cb63f6b792e904e18f2242f.zip cpython-20c258c6928b878e0cb63f6b792e904e18f2242f.tar.gz cpython-20c258c6928b878e0cb63f6b792e904e18f2242f.tar.bz2 |
gh-98852: Fix subscription of type aliases (GH-98920)
Fix subscription of type aliases containing bare generic types or types
like TypeVar: for example tuple[A, T][int] and tuple[TypeVar, T][int],
where A is a generic type, and T is a type variable.
(cherry picked from commit 0e15c31c7e9907fdbe38a3f419b669fed5bb3b33)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/genericaliasobject.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c index 19f011f..77acd1b 100644 --- a/Objects/genericaliasobject.c +++ b/Objects/genericaliasobject.c @@ -458,6 +458,13 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje } for (Py_ssize_t iarg = 0, jarg = 0; iarg < nargs; iarg++) { PyObject *arg = PyTuple_GET_ITEM(args, iarg); + if (PyType_Check(arg)) { + Py_INCREF(arg); + PyTuple_SET_ITEM(newargs, jarg, arg); + jarg++; + continue; + } + int unpack = _is_unpacked_typevartuple(arg); if (unpack < 0) { Py_DECREF(newargs); |