[Python-checkins] CVS: python/dist/src/Lib copy_reg.py,1.6,1.7

Guido van Rossum gvanrossum@users.sourceforge.net
Tue, 25 Sep 2001 12:46:07 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv29596

Modified Files:
	copy_reg.py 
Log Message:
_reconstructor(): there's no need for tricks with assignment to
__class__.  The __new__ protocol is up to this.  (Thanks to Tim for
pointing this out.)


Index: copy_reg.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/copy_reg.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** copy_reg.py	2001/09/25 16:25:58	1.6
--- copy_reg.py	2001/09/25 19:46:05	1.7
***************
*** 37,50 ****
  # Support for picking new-style objects
  
- _dummy_classes = {}
- 
  def _reconstructor(cls, base, state):
!     dummy = _dummy_classes.get(base)
!     if dummy is None:
!         class dummy(base): pass
!         _dummy_classes[base] = dummy
!     obj = dummy(state)
!     obj._foo = 1; del obj._foo # hack to create __dict__
!     obj.__class__ = cls
      return obj
  _reconstructor.__safe_for_unpickling__ = 1
--- 37,43 ----
  # Support for picking new-style objects
  
  def _reconstructor(cls, base, state):
!     obj = base.__new__(cls, state)
!     base.__init__(obj, state)
      return obj
  _reconstructor.__safe_for_unpickling__ = 1