[Python-checkins] python/dist/src/Lib UserString.py,1.10.18.2,1.10.18.3 string.py,1.60.16.4,1.60.16.5

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
2003年4月11日 11:21:52 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv16801/Lib
Modified Files:
 Tag: release22-maint
	UserString.py string.py 
Log Message:
Backport:
Fix SF bug #697220, string.strip implementation/doc mismatch
Attempt to make all the various string/unicode *strip methods the same.
 * Doc - add doc for when functions were added
 * UserString
 * string/unicode object methods
 * string module functions
'chars' is used for the last parameter everywhere.
Index: UserString.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/UserString.py,v
retrieving revision 1.10.18.2
retrieving revision 1.10.18.3
diff -C2 -d -r1.10.18.2 -r1.10.18.3
*** UserString.py	22 Apr 2002 11:57:04 -0000	1.10.18.2
--- UserString.py	11 Apr 2003 18:21:11 -0000	1.10.18.3
***************
*** 109,113 ****
 def ljust(self, width): return self.__class__(self.data.ljust(width))
 def lower(self): return self.__class__(self.data.lower())
! def lstrip(self, sep=None): return self.__class__(self.data.lstrip(sep))
 def replace(self, old, new, maxsplit=-1):
 return self.__class__(self.data.replace(old, new, maxsplit))
--- 109,113 ----
 def ljust(self, width): return self.__class__(self.data.ljust(width))
 def lower(self): return self.__class__(self.data.lower())
! def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars))
 def replace(self, old, new, maxsplit=-1):
 return self.__class__(self.data.replace(old, new, maxsplit))
***************
*** 117,121 ****
 return self.data.rindex(sub, start, end)
 def rjust(self, width): return self.__class__(self.data.rjust(width))
! def rstrip(self, sep=None): return self.__class__(self.data.rstrip(sep))
 def split(self, sep=None, maxsplit=-1):
 return self.data.split(sep, maxsplit)
--- 117,121 ----
 return self.data.rindex(sub, start, end)
 def rjust(self, width): return self.__class__(self.data.rjust(width))
! def rstrip(self, chars=None): return self.__class__(self.data.rstrip(chars))
 def split(self, sep=None, maxsplit=-1):
 return self.data.split(sep, maxsplit)
***************
*** 123,127 ****
 def startswith(self, prefix, start=0, end=sys.maxint):
 return self.data.startswith(prefix, start, end)
! def strip(self, sep=None): return self.__class__(self.data.strip(sep))
 def swapcase(self): return self.__class__(self.data.swapcase())
 def title(self): return self.__class__(self.data.title())
--- 123,127 ----
 def startswith(self, prefix, start=0, end=sys.maxint):
 return self.data.startswith(prefix, start, end)
! def strip(self, chars=None): return self.__class__(self.data.strip(chars))
 def swapcase(self): return self.__class__(self.data.swapcase())
 def title(self): return self.__class__(self.data.title())
Index: string.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/string.py,v
retrieving revision 1.60.16.4
retrieving revision 1.60.16.5
diff -C2 -d -r1.60.16.4 -r1.60.16.5
*** string.py	14 Nov 2002 03:32:08 -0000	1.60.16.4
--- string.py	11 Apr 2003 18:21:12 -0000	1.60.16.5
***************
*** 79,83 ****
 Return a copy of the string s with leading and trailing
 whitespace removed.
! If chars is given and not None, remove characters in sep instead.
 If chars is unicode, S will be converted to unicode before stripping.
 
--- 79,83 ----
 Return a copy of the string s with leading and trailing
 whitespace removed.
! If chars is given and not None, remove characters in chars instead.
 If chars is unicode, S will be converted to unicode before stripping.
 
***************
*** 86,106 ****
 
 # Strip leading tabs and spaces
! def lstrip(s):
! """lstrip(s) -> string
 
 Return a copy of the string s with leading whitespace removed.
 
 """
! return s.lstrip()
 
 # Strip trailing tabs and spaces
! def rstrip(s):
! """rstrip(s) -> string
 
! Return a copy of the string s with trailing whitespace
! removed.
 
 """
! return s.rstrip()
 
 
--- 86,109 ----
 
 # Strip leading tabs and spaces
! def lstrip(s, chars=None):
! """lstrip(s [,chars]) -> string
 
 Return a copy of the string s with leading whitespace removed.
+ If chars is given and not None, remove characters in chars instead.
+ If chars is unicode, S will be converted to unicode before stripping.
 
 """
! return s.lstrip(chars)
 
 # Strip trailing tabs and spaces
! def rstrip(s, chars=None):
! """rstrip(s [,chars]) -> string
 
! Return a copy of the string s with trailing whitespace removed.
! If chars is given and not None, remove characters in chars instead.
! If chars is unicode, S will be converted to unicode before stripping.
 
 """
! return s.rstrip(chars)
 
 

AltStyle によって変換されたページ (->オリジナル) /