From 5f12d755a82312673c35e8224b2bde7ced159c52 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= <martin@v.loewis.de>
Date: Sun, 30 Sep 2001 20:15:41 +0000
Subject: Properly detect recursive structures. Adopted from patch #465298.

---
 Lib/xmlrpclib.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py
index 9f96163..ea4f932 100644
--- a/Lib/xmlrpclib.py
+++ b/Lib/xmlrpclib.py
@@ -490,6 +490,10 @@ class Marshaller:
                 raise TypeError, "cannot marshal recursive data structures"
             self.memo[i] = None
 
+    def endcontainer(self, value):
+        if value:
+            del self.memo[id(value)]
+
     def dump_array(self, value):
         self.container(value)
         write = self.write
@@ -497,6 +501,7 @@ class Marshaller:
         for v in value:
             self.__dump(v)
         write("</data></array></value>\n")
+        self.endcontainer(value)
     dispatch[TupleType] = dump_array
     dispatch[ListType] = dump_array
 
@@ -513,6 +518,7 @@ class Marshaller:
             self.__dump(v)
             write("</member>\n")
         write("</struct></value>\n")
+        self.endcontainer(value)
     dispatch[DictType] = dump_struct
 
     def dump_instance(self, value):
-- 
cgit v0.12

