summaryrefslogtreecommitdiff
path: root/Lib/test/test_string.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2002-04-17 21:34:05 +0000
committerWalter Dörwald <walter@livinglogic.de>2002-04-17 21:34:05 +0000
commit2ee4be077534577eed52c136d10d9f8c0731e864 (patch)
tree2c3021ea407fedc62b685d330a8081869456c605 /Lib/test/test_string.py
parent1ec71ea48e344a556bf1ecfbe5d31913f48c091c (diff)
downloadcpython-git-2ee4be077534577eed52c136d10d9f8c0731e864.tar.gz
Apply diff3.txt from SF patch http://www.python.org/sf/536241
If a str or unicode method returns the original object, make sure that for str and unicode subclasses the original will not be returned. This should prevent SF bug http://www.python.org/sf/460020 from reappearing.
Diffstat (limited to 'Lib/test/test_string.py')
-rw-r--r--Lib/test/test_string.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py
index 4c5a60aa2c..8f0ea47bd0 100644
--- a/Lib/test/test_string.py
+++ b/Lib/test/test_string.py
@@ -22,6 +22,25 @@ def test(name, input, output, *args):
except:
value = sys.exc_type
f = name
+ if value == output:
+ # if the original is returned make sure that
+ # this doesn't happen with subclasses
+ if value is input:
+ class ssub(str):
+ def __repr__(self):
+ return 'ssub(%r)' % str.__repr__(self)
+ input = ssub(input)
+ try:
+ f = getattr(input, name)
+ value = apply(f, args)
+ except AttributeError:
+ f = getattr(string, name)
+ value = apply(f, (input,) + args)
+ if value is input:
+ if verbose:
+ print 'no'
+ print '*',f, `input`, `output`, `value`
+ return
if value != output:
if verbose:
print 'no'