[3.10] bpo-44468: Never skip base classes in typing.get_type_hints(), even with invalid .__module__. (GH-26862) (GH-26920)

(cherry picked from commit 7569c0fe91)


Co-authored-by: will-ca <willchencontact@gmail.com>

Automerge-Triggered-By: GH:gvanrossum
This commit is contained in:
Miss Islington (bot) 2021-06-26 16:52:28 -07:00 committed by GitHub
parent 6cd369c48f
commit 3df23b5199
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 11 deletions

View file

@ -1700,10 +1700,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__', {})