[Python-checkins] python/dist/src/Lib ConfigParser.py,1.40,1.41 Cookie.py,1.11,1.12 inspect.py,1.31,1.32

fdrake@sourceforge.net fdrake@sourceforge.net
Thu, 25 Apr 2002 19:29:57 -0700


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

Modified Files:
	ConfigParser.py Cookie.py inspect.py 
Log Message:
Clean up uses of some deprecated features.
Reported by Neal Norwitz on python-dev.


Index: ConfigParser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/ConfigParser.py,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** ConfigParser.py	4 Apr 2002 22:55:58 -0000	1.40
--- ConfigParser.py	26 Apr 2002 02:29:55 -0000	1.41
***************
*** 302,309 ****
  
      def getint(self, section, option):
!         return self.__get(section, string.atoi, option)
  
      def getfloat(self, section, option):
!         return self.__get(section, string.atof, option)
  
      def getboolean(self, section, option):
--- 302,309 ----
  
      def getint(self, section, option):
!         return self.__get(section, int, option)
  
      def getfloat(self, section, option):
!         return self.__get(section, float, option)
  
      def getboolean(self, section, option):

Index: Cookie.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/Cookie.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Cookie.py	2 Aug 2001 07:15:29 -0000	1.11
--- Cookie.py	26 Apr 2002 02:29:55 -0000	1.12
***************
*** 232,235 ****
--- 232,238 ----
             "SmartCookie","Cookie"]
  
+ _nulljoin = ''.join
+ _spacejoin = ' '.join
+ 
  #
  # Define an exception visible to External modules
***************
*** 312,316 ****
  
  def _quote(str, LegalChars=_LegalChars,
!     join=string.join, idmap=string._idmap, translate=string.translate):
      #
      # If the string does not need to be double-quoted,
--- 315,319 ----
  
  def _quote(str, LegalChars=_LegalChars,
!            idmap=string._idmap, translate=string.translate):
      #
      # If the string does not need to be double-quoted,
***************
*** 322,326 ****
          return str
      else:
!         return '"' + join( map(_Translator.get, str, str), "" ) + '"'
  # end _quote
  
--- 325,329 ----
          return str
      else:
!         return '"' + _nulljoin( map(_Translator.get, str, str) ) + '"'
  # end _quote
  
***************
*** 329,333 ****
  _QuotePatt = re.compile(r"[\\].")
  
! def _unquote(str, join=string.join, atoi=string.atoi):
      # If there aren't any doublequotes,
      # then there can't be any special characters.  See RFC 2109.
--- 332,336 ----
  _QuotePatt = re.compile(r"[\\].")
  
! def _unquote(str):
      # If there aren't any doublequotes,
      # then there can't be any special characters.  See RFC 2109.
***************
*** 366,372 ****
          else:                                      # OctalPatt matched
              res.append(str[i:j])
!             res.append( chr( atoi(str[j+1:j+4], 8) ) )
              i = j+4
!     return join(res, "")
  # end _unquote
  
--- 369,375 ----
          else:                                      # OctalPatt matched
              res.append(str[i:j])
!             res.append( chr( int(str[j+1:j+4], 8) ) )
              i = j+4
!     return _nulljoin(res)
  # end _unquote
  
***************
*** 436,440 ****
  
      def __setitem__(self, K, V):
!         K = string.lower(K)
          if not K in self._reserved_keys:
              raise CookieError("Invalid Attribute %s" % K)
--- 439,443 ----
  
      def __setitem__(self, K, V):
!         K = K.lower()
          if not K in self._reserved_keys:
              raise CookieError("Invalid Attribute %s" % K)
***************
*** 443,447 ****
  
      def isReservedKey(self, K):
!         return string.lower(K) in self._reserved_keys
      # end isReservedKey
  
--- 446,450 ----
  
      def isReservedKey(self, K):
!         return K.lower() in self._reserved_keys
      # end isReservedKey
  
***************
*** 451,455 ****
          # First we verify that the key isn't a reserved word
          # Second we make sure it only contains legal characters
!         if string.lower(key) in self._reserved_keys:
              raise CookieError("Attempt to set a reserved key: %s" % key)
          if "" != translate(key, idmap, LegalChars):
--- 454,458 ----
          # First we verify that the key isn't a reserved word
          # Second we make sure it only contains legal characters
!         if key.lower() in self._reserved_keys:
              raise CookieError("Attempt to set a reserved key: %s" % key)
          if "" != translate(key, idmap, LegalChars):
***************
*** 509,513 ****
  
          # Return the result
!         return string.join(result, " ")
      # end OutputString
  # end Morsel class
--- 512,516 ----
  
          # Return the result
!         return _spacejoin(result)
      # end OutputString
  # end Morsel class
***************
*** 593,597 ****
          for K,V in items:
              result.append( V.output(attrs, header) )
!         return string.join(result, sep)
      # end output
  
--- 596,600 ----
          for K,V in items:
              result.append( V.output(attrs, header) )
!         return sep.join(result)
      # end output
  
***************
*** 604,608 ****
          for K,V in items:
              L.append( '%s=%s' % (K,repr(V.value) ) )
!         return '<%s: %s>' % (self.__class__.__name__, string.join(L))
  
      def js_output(self, attrs=None):
--- 607,611 ----
          for K,V in items:
              L.append( '%s=%s' % (K,repr(V.value) ) )
!         return '<%s: %s>' % (self.__class__.__name__, _spacejoin(L))
  
      def js_output(self, attrs=None):
***************
*** 613,617 ****
          for K,V in items:
              result.append( V.js_output(attrs) )
!         return string.join(result, "")
      # end js_output
  
--- 616,620 ----
          for K,V in items:
              result.append( V.js_output(attrs) )
!         return _nulljoin(result)
      # end js_output
  
***************
*** 649,653 ****
                  if M:
                      M[ K[1:] ] = V
!             elif string.lower(K) in Morsel._reserved_keys:
                  if M:
                      M[ K ] = _unquote(V)
--- 652,656 ----
                  if M:
                      M[ K[1:] ] = V
!             elif K.lower() in Morsel._reserved_keys:
                  if M:
                      M[ K ] = _unquote(V)

Index: inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/inspect.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** inspect.py	28 Mar 2002 23:01:56 -0000	1.31
--- inspect.py	26 Apr 2002 02:29:55 -0000	1.32
***************
*** 770,774 ****
          1/0
      except ZeroDivisionError:
!         return sys.exc_traceback.tb_frame.f_back
  
  if hasattr(sys, '_getframe'): currentframe = sys._getframe
--- 770,774 ----
          1/0
      except ZeroDivisionError:
!         return sys.exc_info()[2].tb_frame.f_back
  
  if hasattr(sys, '_getframe'): currentframe = sys._getframe
***************
*** 780,782 ****
  def trace(context=1):
      """Return a list of records for the stack below the current exception."""
!     return getinnerframes(sys.exc_traceback, context)
--- 780,782 ----
  def trace(context=1):
      """Return a list of records for the stack below the current exception."""
!     return getinnerframes(sys.exc_info()[2], context)