[Python-checkins] python/dist/src/Lib pickle.py,1.148,1.149

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Sun, 09 Feb 2003 09:19:46 -0800


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

Modified Files:
	pickle.py 
Log Message:
Rename 'proto' keyword arg to 'protocol' .  Greg Ward's suggestion.


Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.148
retrieving revision 1.149
diff -C2 -d -r1.148 -r1.149
*** pickle.py	6 Feb 2003 22:57:00 -0000	1.148
--- pickle.py	9 Feb 2003 17:19:41 -0000	1.149
***************
*** 168,176 ****
  class Pickler:
  
!     def __init__(self, file, proto=None, bin=None):
          """This takes a file-like object for writing a pickle data stream.
  
!         The optional proto argument tells the pickler to use the given
!         protocol; supported protocols are 0, 1, 2.  The default
          protocol is 0, to be backwards compatible.  (Protocol 0 is the
          only protocol that can be written to a file opened in text
--- 168,176 ----
  class Pickler:
  
!     def __init__(self, file, protocol=None, bin=None):
          """This takes a file-like object for writing a pickle data stream.
  
!         The optional protocol argument tells the pickler to use the
!         given protocol; supported protocols are 0, 1, 2.  The default
          protocol is 0, to be backwards compatible.  (Protocol 0 is the
          only protocol that can be written to a file opened in text
***************
*** 192,211 ****
  
          """
!         if proto is not None and bin is not None:
!             raise ValueError, "can't specify both 'proto' and 'bin' arguments"
          if bin is not None:
              warnings.warn("The 'bin' argument to Pickler() is deprecated",
                            PendingDeprecationWarning)
!             proto = bin
!         if proto is None:
!             proto = 0
!         if proto < 0:
!             proto = 2
!         elif proto not in (0, 1, 2):
              raise ValueError, "pickle protocol must be 0, 1 or 2"
          self.write = file.write
          self.memo = {}
!         self.proto = int(proto)
!         self.bin = proto >= 1
          self.fast = 0
  
--- 192,211 ----
  
          """
!         if protocol is not None and bin is not None:
!             raise ValueError, "can't specify both 'protocol' and 'bin'"
          if bin is not None:
              warnings.warn("The 'bin' argument to Pickler() is deprecated",
                            PendingDeprecationWarning)
!             protocol = bin
!         if protocol is None:
!             protocol = 0
!         if protocol < 0:
!             protocol = 2
!         elif protocol not in (0, 1, 2):
              raise ValueError, "pickle protocol must be 0, 1 or 2"
          self.write = file.write
          self.memo = {}
!         self.proto = int(protocol)
!         self.bin = protocol >= 1
          self.fast = 0
  
***************
*** 1370,1379 ****
      from StringIO import StringIO
  
! def dump(obj, file, proto=None, bin=None):
!     Pickler(file, proto, bin).dump(obj)
  
! def dumps(obj, proto=None, bin=None):
      file = StringIO()
!     Pickler(file, proto, bin).dump(obj)
      return file.getvalue()
  
--- 1370,1379 ----
      from StringIO import StringIO
  
! def dump(obj, file, protocol=None, bin=None):
!     Pickler(file, protocol, bin).dump(obj)
  
! def dumps(obj, protocol=None, bin=None):
      file = StringIO()
!     Pickler(file, protocol, bin).dump(obj)
      return file.getvalue()