mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
1ec71ea48e
commit
2ee4be0775
2 changed files with 41 additions and 0 deletions
|
@ -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'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue