mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #6477: Added support for pickling the types of built-in singletons.
This commit is contained in:
parent
f8ceb04fcf
commit
19b6fa6ebb
6 changed files with 58 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue