mirror of
https://github.com/python/cpython.git
synced 2025-12-09 02:35:14 +00:00
_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.
This commit is contained in:
parent
bb2501f638
commit
2a6f5b38ac
1 changed files with 2 additions and 0 deletions
|
|
@ -53,6 +53,8 @@ def _reduce(self):
|
||||||
if base is object:
|
if base is object:
|
||||||
state = None
|
state = None
|
||||||
else:
|
else:
|
||||||
|
if base is self.__class__:
|
||||||
|
raise TypeError, "can't pickle %s objects" % base.__name__
|
||||||
state = base(self)
|
state = base(self)
|
||||||
args = (self.__class__, base, state)
|
args = (self.__class__, base, state)
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue