]> granicus.if.org Git - python/commitdiff
save_tuple(): I believe the new code for TUPLE{1,2,3} in proto 2 was
authorTim Peters <tim.peters@gmail.com>
Tue, 28 Jan 2003 05:34:53 +0000 (05:34 +0000)
committerTim Peters <tim.peters@gmail.com>
Tue, 28 Jan 2003 05:34:53 +0000 (05:34 +0000)
incorrect for recursive tuples.  Tried to repair; seems to work OK, but
there are no checked-in tests for this yet.

Lib/pickle.py

index 95bdd269130d4c2802eb2e69e4691db91e7064d2..6f4ee5c9ace9d1928d3207ed315e836928aa1e68 100644 (file)
@@ -471,14 +471,17 @@ class Pickler:
                 if proto >= 2:
                     for element in object:
                         save(element)
-                    # Subtle.  Same as in the big comment below
+                    # Subtle.  Same as in the big comment below.
                     if id(object) in memo:
                         get = self.get(memo[id(object)][0])
-                        write(POP_MARK + get)
+                        write(POP * n + get)
                     else:
                         write(_tuplesize2code[n])
+                        self.memoize(object)
                     return
 
+        # proto 0, or proto 1 and tuple isn't empty, or proto > 1 and tuple
+        # has more than 3 elements.
         write(MARK)
         for element in object:
             save(element)