From: Michael W. Hudson Date: Fri, 28 Dec 2001 15:48:09 +0000 (+0000) Subject: Backport gvanrossum's checkin of version 1.10: X-Git-Tag: v2.2.1c1~256 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d444067ad38a59193a1b88522bd54709292bc011;p=thirdparty%2FPython%2Fcpython.git Backport gvanrossum's checkin of version 1.10: _reduce(): Avoid infinite recursion in the pickler when self.__class__ 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. --- diff --git a/Lib/copy_reg.py b/Lib/copy_reg.py index 92cbd5345b71..8a3550aad3ff 100644 --- a/Lib/copy_reg.py +++ b/Lib/copy_reg.py @@ -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: