[Python-checkins] python/dist/src/Lib copy_reg.py,1.19,1.20

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Thu, 13 Feb 2003 08:25:40 -0800


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

Modified Files:
	copy_reg.py 
Log Message:
SF patch #685738 by Michael Stone.

This changes the default __new__ to refuse arguments iff tp_init is the
default __init__ implementation -- thus making it a TypeError when you
try to pass arguments to a constructor if the class doesn't override at
least __init__ or __new__.


Index: copy_reg.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/copy_reg.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** copy_reg.py	10 Feb 2003 21:31:25 -0000	1.19
--- copy_reg.py	13 Feb 2003 16:25:37 -0000	1.20
***************
*** 34,42 ****
  pickle(type(1j), pickle_complex, complex)
  
! # Support for picking new-style objects
  
  def _reconstructor(cls, base, state):
!     obj = base.__new__(cls, state)
!     base.__init__(obj, state)
      return obj
  
--- 34,45 ----
  pickle(type(1j), pickle_complex, complex)
  
! # Support for pickling new-style objects
  
  def _reconstructor(cls, base, state):
!     if base is object:
!         obj = object.__new__(cls)
!     else:
!         obj = base.__new__(cls, state)
!         base.__init__(obj, state)
      return obj