summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorwill-ca <willchencontact@gmail.com>2021-06-26 23:31:32 (GMT)
committerGitHub <noreply@github.com>2021-06-26 23:31:32 (GMT)
commit7569c0fe91dfcf562dee8c29798ecda74d738aa8 (patch)
tree3561e803ea17399dc8347028cd6fdc4e3ef860d5 /Lib/typing.py
parent521ba8892ef367c45bf1647b04a726d3f553637c (diff)
downloadcpython-7569c0fe91dfcf562dee8c29798ecda74d738aa8.zip
cpython-7569c0fe91dfcf562dee8c29798ecda74d738aa8.tar.gz
cpython-7569c0fe91dfcf562dee8c29798ecda74d738aa8.tar.bz2
bpo-44468: Never skip base classes in `typing.get_type_hints()`, even with invalid `.__module__`. (GH-26862)
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 00a0df5..2287f05 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1701,10 +1701,7 @@ def get_type_hints(obj, globalns=None, localns=None, include_extras=False):
hints = {}
for base in reversed(obj.__mro__):
if globalns is None:
- try:
- base_globals = sys.modules[base.__module__].__dict__
- except KeyError:
- continue
+ base_globals = getattr(sys.modules.get(base.__module__, None), '__dict__', {})
else:
base_globals = globalns
ann = base.__dict__.get('__annotations__', {})