diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2013-12-01 00:06:39 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2013-12-01 00:06:39 (GMT) |
commit | 19b6fa6ebb887e498437b4ae87d6e70b92b4742b (patch) | |
tree | 06c58ae3259eb7bead5356406c4fc7fefa0e34d9 /Lib/pickle.py | |
parent | f8ceb04fcfb2fac63c832639442e69d8902a48b8 (diff) | |
download | cpython-19b6fa6ebb887e498437b4ae87d6e70b92b4742b.zip cpython-19b6fa6ebb887e498437b4ae87d6e70b92b4742b.tar.gz cpython-19b6fa6ebb887e498437b4ae87d6e70b92b4742b.tar.bz2 |
Issue #6477: Added support for pickling the types of built-in singletons.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r-- | Lib/pickle.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index d62f014..386ffba 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -728,9 +728,18 @@ class _Pickler: self.memoize(obj) + def save_type(self, obj): + if obj is type(None): + return self.save_reduce(type, (None,), obj=obj) + elif obj is type(NotImplemented): + return self.save_reduce(type, (NotImplemented,), obj=obj) + elif obj is type(...): + return self.save_reduce(type, (...,), obj=obj) + return self.save_global(obj) + dispatch[FunctionType] = save_global dispatch[BuiltinFunctionType] = save_global - dispatch[type] = save_global + dispatch[type] = save_type # Pickling helpers |