]> granicus.if.org Git - python/commitdiff
Don't call constructor() from pickle().
authorJeremy Hylton <jeremy@alum.mit.edu>
Thu, 26 Jun 2003 23:20:20 +0000 (23:20 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Thu, 26 Jun 2003 23:20:20 +0000 (23:20 +0000)
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.

Lib/copy_reg.py

index 0477bcb541bd99109c20b8f2a6da9b770b75ad86..97bef4100f64a6bf5231fc8fc3737946c690c9eb 100644 (file)
@@ -12,6 +12,7 @@ __all__ = ["pickle", "constructor",
 dispatch_table = {}
 
 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")
 
@@ -19,10 +20,9 @@ def pickle(ob_type, pickle_function, constructor_ob=None):
         raise TypeError("reduction functions must be callable")
     dispatch_table[ob_type] = pickle_function
 
-    if constructor_ob is not None:
-        constructor(constructor_ob)
-
 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")