summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 7aab8db..f4fb08f 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -600,7 +600,10 @@ class TypeVar(_Final, _Immutable, _root=True):
self.__bound__ = _type_check(bound, "Bound must be a type.")
else:
self.__bound__ = None
- def_mod = sys._getframe(1).f_globals['__name__'] # for pickling
+ try:
+ def_mod = sys._getframe(1).f_globals.get('__name__', '__main__') # for pickling
+ except (AttributeError, ValueError):
+ def_mod = None
if def_mod != 'typing':
self.__module__ = def_mod