[3.8] bpo-40398: Fix typing.get_args() for special generic aliases. (GH-19720) (GH-19857)
(cherry picked from commit 6292be7adf247589bbf03524f8883cb4cb61f3e9)
diff --git a/Lib/typing.py b/Lib/typing.py
index f4fb08f..589eea9 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1300,7 +1300,7 @@
get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int])
get_args(Callable[[], T][int]) == ([], int)
"""
- if isinstance(tp, _GenericAlias):
+ if isinstance(tp, _GenericAlias) and not tp._special:
res = tp.__args__
if get_origin(tp) is collections.abc.Callable and res[0] is not Ellipsis:
res = (list(res[:-1]), res[-1])