@@ -773,56 +773,6 @@ def __getattribute__(self, item):
773773 if type (operator .attrgetter ) is type :
774774 dispatch [operator .attrgetter ] = save_attrgetter
775775
776- def save_reduce (self , func , args , state = None ,
777- listitems = None , dictitems = None , obj = None ):
778- # Assert that args is a tuple or None
779- if not isinstance (args , tuple ):
780- raise pickle .PicklingError ("args from reduce() should be a tuple" )
781-
782- # Assert that func is callable
783- if not hasattr (func , '__call__' ):
784- raise pickle .PicklingError ("func from reduce should be callable" )
785-
786- save = self .save
787- write = self .write
788-
789- # Protocol 2 special case: if func's name is __newobj__, use NEWOBJ
790- if self .proto >= 2 and getattr (func , "__name__" , "" ) == "__newobj__" :
791- cls = args [0 ]
792- if not hasattr (cls , "__new__" ):
793- raise pickle .PicklingError (
794- "args[0] from __newobj__ args has no __new__" )
795- if obj is not None and cls is not obj .__class__ :
796- raise pickle .PicklingError (
797- "args[0] from __newobj__ args has the wrong class" )
798- args = args [1 :]
799- save (cls )
800-
801- save (args )
802- write (pickle .NEWOBJ )
803- else :
804- save (func )
805- save (args )
806- write (pickle .REDUCE )
807-
808- if obj is not None :
809- self .memoize (obj )
810-
811- # More new special cases (that work with older protocols as
812- # well): when __reduce__ returns a tuple with 4 or 5 items,
813- # the 4th and 5th item should be iterators that provide list
814- # items and dict items (as (key, value) tuples), or None.
815-
816- if listitems is not None :
817- self ._batch_appends (listitems )
818-
819- if dictitems is not None :
820- self ._batch_setitems (dictitems )
821-
822- if state is not None :
823- save (state )
824- write (pickle .BUILD )
825-
826776 def save_partial (self , obj ):
827777 """Partial objects do not serialize correctly in python2.x -- this fixes the bugs"""
828778 self .save_reduce (_genpartial , (obj .func , obj .args , obj .keywords ))
0 commit comments