]> granicus.if.org Git - python/commitdiff
_reduce(): Avoid infinite recursion in the pickler when self.__class__
authorGuido van Rossum <guido@python.org>
Thu, 27 Dec 2001 16:27:28 +0000 (16:27 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 27 Dec 2001 16:27:28 +0000 (16:27 +0000)
doesn't have the _HEAPTYPE flag set, e.g. for time.struct_time and
posix.stat_result.

This fixes the immediate symptoms of SF bug #496873 (cPickle /
time.struct_time loop), replacing the infinite loop with an exception.

Lib/copy_reg.py

index 92cbd5345b7163995ccb2961c1183fc9af7e4460..8a3550aad3ff4e24dbe5cf3adc611ba7b9740e42 100644 (file)
@@ -53,6 +53,8 @@ def _reduce(self):
     if base is object:
         state = None
     else:
+        if base is self.__class__:
+            raise TypeError, "can't pickle %s objects" % base.__name__
         state = base(self)
     args = (self.__class__, base, state)
     try: