Issue #6477: Added support for pickling the types of built-in singletons.
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 @@
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