[Python-checkins] python/dist/src/Lib pickle.py,1.139,1.140

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sun, 02 Feb 2003 12:29:40 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv28209/Lib

Modified Files:
	pickle.py 
Log Message:
cPickle support for TUPLE[123].  Incidentally plugged several undetected
overflow holes in Pdata_grow().


Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.139
retrieving revision 1.140
diff -C2 -d -r1.139 -r1.140
*** pickle.py	2 Feb 2003 07:51:32 -0000	1.139
--- pickle.py	2 Feb 2003 20:29:38 -0000	1.140
***************
*** 622,627 ****
  
          n = len(obj)
!         if n == 0 and proto:
!             write(EMPTY_TUPLE)
              return
  
--- 622,630 ----
  
          n = len(obj)
!         if n == 0:
!             if proto:
!                 write(EMPTY_TUPLE)
!             else:
!                 write(MARK + TUPLE)
              return
  
***************
*** 640,644 ****
              return
  
!         # proto 0, or proto 1 and tuple isn't empty, or proto > 1 and tuple
          # has more than 3 elements.
          write(MARK)
--- 643,647 ----
              return
  
!         # proto 0 or proto 1 and tuple isn't empty, or proto > 1 and tuple
          # has more than 3 elements.
          write(MARK)
***************
*** 646,650 ****
              save(element)
  
!         if n and id(obj) in memo:
              # Subtle.  d was not in memo when we entered save_tuple(), so
              # the process of saving the tuple's elements must have saved
--- 649,653 ----
              save(element)
  
!         if id(obj) in memo:
              # Subtle.  d was not in memo when we entered save_tuple(), so
              # the process of saving the tuple's elements must have saved
***************
*** 661,668 ****
              return
  
!         # No recursion (including the empty-tuple case for protocol 0).
          self.write(TUPLE)
!         if obj:                      # No need to memoize empty tuple
!             self.memoize(obj)
  
      dispatch[TupleType] = save_tuple
--- 664,670 ----
              return
  
!         # No recursion.
          self.write(TUPLE)
!         self.memoize(obj)
  
      dispatch[TupleType] = save_tuple