[Python-checkins] python/nondist/peps pep-0307.txt,1.14,1.15
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Fri, 07 Feb 2003 10:11:34 -0800
Update of /cvsroot/python/python/nondist/peps
In directory sc8-pr-cvs1:/tmp/cvs-serv5765
Modified Files:
pep-0307.txt
Log Message:
Add posting-date. Add note about the copy module. Remove TBD -- this
PEP is complete AFAIAC.
Index: pep-0307.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0307.txt,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** pep-0307.txt 6 Feb 2003 20:38:30 -0000 1.14
--- pep-0307.txt 7 Feb 2003 18:11:29 -0000 1.15
***************
*** 8,12 ****
Content-Type: text/plain
Created: 31-Jan-2003
! Post-History: None
--- 8,12 ----
Content-Type: text/plain
Created: 31-Jan-2003
! Post-History: 7-Feb-2003
***************
*** 600,606 ****
! TBD
! The rest of this PEP is still under construction!
--- 600,646 ----
! The copy module
! Traditionally, the copy module has supported an extended subset of
! the pickling APIs for customizing the copy() and deepcopy()
! operations.
!
! In particular, besides checking for a __copy__ or __deepcopy__
! method, copy() and deepcopy() have always looked for __reduce__,
! and for classic classes, have looked for __getinitargs__,
! __getstate__ and __setstate__.
!
! In Python 2.2, the default __reduce__ inherited from 'object' made
! copying simple new-style classes possible, but slots and various
! other special cases were not covered.
!
! In Python 2.3, several changes are made to the copy module:
!
! - The four- and five-argument return values of __reduce__ are
! supported.
!
! - Before looking for a __reduce__ method, the
! copy_reg.dispatch_table is consulted, just like for pickling.
!
! - When the __reduce__ method is inherited from object, it is
! (unconditionally) replaced by a better one that uses the same
! APIs as pickle protocol 2: __getnewargs__, __getstate__, and
! __setstate__, handling list and dict subclasses, and handling
! slots.
!
! As a consequence of the latter change, certain new-style classes
! that were copyable under Python 2.2 are not copyable under Python
! 2.3. (These classes are also not picklable using pickle protocol
! 2.) A minimal example of such a class:
!
! class C(object):
! def __new__(cls, a):
! return object.__new__(cls)
!
! The problem only occurs when __new__ is overridden and has at
! least one mandatory argument in addition to the class argument.
!
! To fix this, a __getnewargs__ method should be added that returns
! the appropriate argument tuple (excluding the class).