[Python-checkins] python/dist/src/Lib UserString.py,1.10.18.1,1.10.18.2 string.py,1.60.16.1,1.60.16.2
doerwalter@sourceforge.net
doerwalter@sourceforge.net
Mon, 22 Apr 2002 04:57:07 -0700
- Previous message: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex,1.80.6.4,1.80.6.5
- Next message: [Python-checkins] python/dist/src/Lib/test string_tests.py,1.10.16.1,1.10.16.2 test_string.py,1.15,1.15.6.1 test_unicode.py,1.47.6.1,1.47.6.2 test_userstring.py,1.5,1.5.24.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv17892/Lib
Modified Files:
Tag: release22-maint
UserString.py string.py
Log Message:
Backport the following changes:
Misc/NEWS 1.387->1.388
Lib/test/string_tests.py 1.10->1.11, 1.12->1.14,
Lib/test/test_unicode.py 1.50->1.51, 1.53->1.54, 1.55->1.56
Lib/test/test_string.py 1.15->1.16
Lib/string.py 1.61->1.63
Lib/test/test_userstring.py 1.5->1.6, 1.11, 1.12
Objects/stringobject.c 2.156->2.159
Objects/unicodeobject.c 2.137->2.139
Doc/lib/libstdtypes.tec 1.87->1.88
Add a method zfill to str, unicode and UserString
and change Lib/string.py accordingly
(see SF patch http://www.python.org/sf/536241)
This also adds Guido's fix to test_userstring.py
and the subinstance checks in test_string.py
and test_unicode.py.
Index: UserString.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/UserString.py,v
retrieving revision 1.10.18.1
retrieving revision 1.10.18.2
diff -C2 -d -r1.10.18.1 -r1.10.18.2
*** UserString.py 18 Apr 2002 05:17:53 -0000 1.10.18.1
--- UserString.py 22 Apr 2002 11:57:04 -0000 1.10.18.2
***************
*** 129,132 ****
--- 129,133 ----
return self.__class__(self.data.translate(*args))
def upper(self): return self.__class__(self.data.upper())
+ def zfill(self, width): return self.__class__(self.data.zfill(width))
class MutableString(UserString):
Index: string.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/string.py,v
retrieving revision 1.60.16.1
retrieving revision 1.60.16.2
diff -C2 -d -r1.60.16.1 -r1.60.16.2
*** string.py 30 Jan 2002 16:15:59 -0000 1.60.16.1
--- string.py 22 Apr 2002 11:57:05 -0000 1.60.16.2
***************
*** 191,195 ****
_int = int
_long = long
! _StringType = type('')
# Convert string to float
--- 191,198 ----
_int = int
_long = long
! try:
! _StringTypes = (str, unicode)
! except NameError:
! _StringTypes = (str,)
# Convert string to float
***************
*** 277,288 ****
"""
! if type(x) == type(''): s = x
! else: s = `x`
! n = len(s)
! if n >= width: return s
! sign = ''
! if s[0] in ('-', '+'):
! sign, s = s[0], s[1:]
! return sign + '0'*(width-n) + s
# Expand tabs in a string.
--- 280,286 ----
"""
! if not isinstance(x, _StringTypes):
! x = repr(x)
! return x.zfill(width)
# Expand tabs in a string.
- Previous message: [Python-checkins] python/dist/src/Doc/lib libstdtypes.tex,1.80.6.4,1.80.6.5
- Next message: [Python-checkins] python/dist/src/Lib/test string_tests.py,1.10.16.1,1.10.16.2 test_string.py,1.15,1.15.6.1 test_unicode.py,1.47.6.1,1.47.6.2 test_userstring.py,1.5,1.5.24.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]