aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbenedwards14 <53377856+benedwards14@users.noreply.github.com>2019-11-21 17:24:58 +0000
committerIvan Levkivskyi <levkivskyi@gmail.com>2019-11-21 17:24:58 +0000
commit0aca3a3a1e68b4ca2d334ab5255dfc267719096e (patch)
tree49924b3d2c93eddef6fc735c49a6177b0d29744d /Lib/typing.py
parentCorrect release version to 3.9 for RERAISE and WITH_EXCEPT_START bytecodes. (... (diff)
downloadcpython-0aca3a3a1e68b4ca2d334ab5255dfc267719096e.tar.gz
cpython-0aca3a3a1e68b4ca2d334ab5255dfc267719096e.tar.bz2
cpython-0aca3a3a1e68b4ca2d334ab5255dfc267719096e.zip
bpo-37838: get_type_hints for wrapped functions with forward reference (GH-17126)
https://bugs.python.org/issue37838
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 27be37a369a..5523ee01e1f 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1234,7 +1234,11 @@ def get_type_hints(obj, globalns=None, localns=None):
if isinstance(obj, types.ModuleType):
globalns = obj.__dict__
else:
- globalns = getattr(obj, '__globals__', {})
+ nsobj = obj
+ # Find globalns for the unwrapped object.
+ while hasattr(nsobj, '__wrapped__'):
+ nsobj = nsobj.__wrapped__
+ globalns = getattr(nsobj, '__globals__', {})
if localns is None:
localns = globalns
elif localns is None: