Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a6f5b3

Browse files
committed
_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.
1 parent bb2501f commit 2a6f5b3

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Lib/copy_reg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def _reduce(self):
5353
if base is object:
5454
state = None
5555
else:
56+
if base is self.__class__:
57+
raise TypeError, "can't pickle %s objects" % base.__name__
5658
state = base(self)
5759
args = (self.__class__, base, state)
5860
try:

0 commit comments

Comments
 (0)