summaryrefslogtreecommitdiff
path: root/Lib/typing.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2015-11-19 08:16:31 -0800
committerGuido van Rossum <guido@python.org>2015-11-19 08:16:31 -0800
commit557d1eb0f3ccb9b0bea685a1883dd249cbe6d23a (patch)
treede8211868e4edc01eac2159a486a41b739a03285 /Lib/typing.py
parent05e3090e3a886b86e8b498247c43a14729ae571c (diff)
downloadcpython-git-557d1eb0f3ccb9b0bea685a1883dd249cbe6d23a.tar.gz
Issue #25665: Make NamedTuple picklable.
Diffstat (limited to 'Lib/typing.py')
-rw-r--r--Lib/typing.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/typing.py b/Lib/typing.py
index 49c4a06973..1757f13822 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -1479,6 +1479,11 @@ def NamedTuple(typename, fields):
fields = [(n, t) for n, t in fields]
cls = collections.namedtuple(typename, [n for n, t in fields])
cls._field_types = dict(fields)
+ # Set the module to the caller's module (otherwise it'd be 'typing').
+ try:
+ cls.__module__ = sys._getframe(1).f_globals.get('__name__', '__main__')
+ except (AttributeError, ValueError):
+ pass
return cls