mirror of
https://github.com/python/cpython.git
synced 2025-10-13 18:33:34 +00:00
Properly detect recursive structures. Adopted from patch #465298.
This commit is contained in:
parent
af5910f025
commit
5f12d755a8
1 changed files with 6 additions and 0 deletions
|
@ -490,6 +490,10 @@ class Marshaller:
|
||||||
raise TypeError, "cannot marshal recursive data structures"
|
raise TypeError, "cannot marshal recursive data structures"
|
||||||
self.memo[i] = None
|
self.memo[i] = None
|
||||||
|
|
||||||
|
def endcontainer(self, value):
|
||||||
|
if value:
|
||||||
|
del self.memo[id(value)]
|
||||||
|
|
||||||
def dump_array(self, value):
|
def dump_array(self, value):
|
||||||
self.container(value)
|
self.container(value)
|
||||||
write = self.write
|
write = self.write
|
||||||
|
@ -497,6 +501,7 @@ class Marshaller:
|
||||||
for v in value:
|
for v in value:
|
||||||
self.__dump(v)
|
self.__dump(v)
|
||||||
write("</data></array></value>\n")
|
write("</data></array></value>\n")
|
||||||
|
self.endcontainer(value)
|
||||||
dispatch[TupleType] = dump_array
|
dispatch[TupleType] = dump_array
|
||||||
dispatch[ListType] = dump_array
|
dispatch[ListType] = dump_array
|
||||||
|
|
||||||
|
@ -513,6 +518,7 @@ class Marshaller:
|
||||||
self.__dump(v)
|
self.__dump(v)
|
||||||
write("</member>\n")
|
write("</member>\n")
|
||||||
write("</struct></value>\n")
|
write("</struct></value>\n")
|
||||||
|
self.endcontainer(value)
|
||||||
dispatch[DictType] = dump_struct
|
dispatch[DictType] = dump_struct
|
||||||
|
|
||||||
def dump_instance(self, value):
|
def dump_instance(self, value):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue