[issue40397] Refactor typing._GenericAlias
Guido van Rossum
report at bugs.python.org
Sat May 9 15:17:34 EDT 2020
Guido van Rossum <guido at python.org> added the comment:
@Serhiy can you look at this? A possible fix might be:
diff --git a/Lib/typing.py b/Lib/typing.py
index 681ab6d21e..adcef1e82b 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -701,7 +701,8 @@ class _GenericAlias(_BaseGenericAlias, _root=True):
arg = subst[arg]
elif isinstance(arg, (_BaseGenericAlias, GenericAlias)):
subargs = tuple(subst[x] for x in arg.__parameters__)
- arg = arg[subargs]
+ if subargs:
+ arg = arg[subargs]
new_args.append(arg)
return self.copy_with(tuple(new_args))
The immediate cause of the problem seems to be that we call arg[subargs] with subargs being (). So arg is a _GenericAlias but its __parameters__ is (). I'm not sure what path was taken previously. :-(
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40397>
_______________________________________
More information about the Python-bugs-list
mailing list