Issue #6477: Added support for pickling the types of built-in singletons.

This commit is contained in:
Alexandre Vassalotti 2013-11-30 16:06:39 -08:00
parent f8ceb04fcf
commit 19b6fa6ebb
6 changed files with 58 additions and 4 deletions

View file

@ -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