[Python-checkins] python/dist/src/Lib copy_reg.py,1.25,1.26

Neal Norwitz neal@metaslash.com
Fri, 27 Jun 2003 09:54:05 -0400


This change broke the test_copy_reg.

test test_copy_reg failed -- Traceback (most recent call last):
  File "/home/neal/build/python/2_3/Lib/test/test_copy_reg.py", line 23, in test_noncallable_constructor
    type(1), int, "not a callable")
  File "/home/neal/build/python/2_3/Lib/unittest.py", line 285, in failUnlessRaises
    raise self.failureException, excName
AssertionError: TypeError

Neal
--

On Thu, Jun 26, 2003 at 04:20:22PM -0700, jhylton@users.sourceforge.net wrote:
> Update of /cvsroot/python/python/dist/src/Lib
> In directory sc8-pr-cvs1:/tmp/cvs-serv12558
> 
> Modified Files:
> 	copy_reg.py 
> Log Message:
> Don't call constructor() from pickle().
> 
> The constructor() call only made sense when it registered the
> constructor as safe for unpickling.  We should probably remove the
> module-global function, but need to worry about backwards
> compatibility.
> 
> 
> 
> Index: copy_reg.py
> ===================================================================
> RCS file: /cvsroot/python/python/dist/src/Lib/copy_reg.py,v
> retrieving revision 1.25
> retrieving revision 1.26
> diff -C2 -d -r1.25 -r1.26
> *** copy_reg.py	7 Jun 2003 20:10:54 -0000	1.25
> --- copy_reg.py	26 Jun 2003 23:20:20 -0000	1.26
> ***************
> *** 13,16 ****
> --- 13,17 ----
>   
>   def pickle(ob_type, pickle_function, constructor_ob=None):
> +     # constructor_ob exists only for backwards compatibility.
>       if type(ob_type) is _ClassType:
>           raise TypeError("copy_reg is not intended for use with classes")
> ***************
> *** 20,27 ****
>       dispatch_table[ob_type] = pickle_function
>   
> -     if constructor_ob is not None:
> -         constructor(constructor_ob)
> - 
>   def constructor(object):
>       if not callable(object):
>           raise TypeError("constructors must be callable")
> --- 21,27 ----
>       dispatch_table[ob_type] = pickle_function
>   
>   def constructor(object):
> +     # XXX This function should be deprecated.  It is a vestige of
> +     # the old __safe_for_unpickling__ code.
>       if not callable(object):
>           raise TypeError("constructors must be callable")
> 
> 
> 
> _______________________________________________
> Python-checkins mailing list
> Python-checkins@python.org
> http://mail.python.org/mailman/listinfo/python-checkins