diff options
author | will-ca <willchencontact@gmail.com> | 2021-06-26 23:31:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-26 23:31:32 (GMT) |
commit | 7569c0fe91dfcf562dee8c29798ecda74d738aa8 (patch) | |
tree | 3561e803ea17399dc8347028cd6fdc4e3ef860d5 /Lib/typing.py | |
parent | 521ba8892ef367c45bf1647b04a726d3f553637c (diff) | |
download | cpython-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.py | 5 |
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__', {}) |