diff options
| author | Karthikeyan Singaravelan <tir.karthi@gmail.com> | 2021-04-12 23:47:25 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-12 11:17:25 -0700 |
| commit | a9cf69df2e031d6157f01289f66ca9cf723ceb5c (patch) | |
| tree | 10b37ae2e40dceb13f0725ac6d52d49ac3dc08ff /Lib/typing.py | |
| parent | 852150ddfe68bc2696fc880175aeb855a0c16ae6 (diff) | |
| download | cpython-git-a9cf69df2e031d6157f01289f66ca9cf723ceb5c.tar.gz | |
bpo-41515: Fix KeyError raised in get_type_hints (GH-25352)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: efahl <36704995+efahl@users.noreply.github.com>
Diffstat (limited to 'Lib/typing.py')
| -rw-r--r-- | Lib/typing.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/typing.py b/Lib/typing.py index 583438e474..dc2a7a4788 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -1628,7 +1628,10 @@ def get_type_hints(obj, globalns=None, localns=None, include_extras=False): hints = {} for base in reversed(obj.__mro__): if globalns is None: - base_globals = sys.modules[base.__module__].__dict__ + try: + base_globals = sys.modules[base.__module__].__dict__ + except KeyError: + continue else: base_globals = globalns ann = base.__dict__.get('__annotations__', {}) |
