[Python-checkins] python/dist/src/Lib/test test_unicode.py,1.67,1.68

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Fri, 23 Aug 2002 11:50:23 -0700


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

Modified Files:
	test_unicode.py 
Log Message:
Fix SF bug 599128, submitted by Inyeol Lee: .replace() would do the
wrong thing for a unicode subclass when there were zero string
replacements.  The example given in the SF bug report was only one way
to trigger this; replacing a string of length >= 2 that's not found is
another.  The code would actually write outside allocated memory if
replacement string was longer than the search string.

(I wonder how many more of these are lurking?  The unicode code base
is full of wonders.)

Bugfix candidate; this same bug is present in 2.2.1.


Index: test_unicode.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_unicode.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -C2 -d -r1.67 -r1.68
*** test_unicode.py	23 Aug 2002 18:21:26 -0000	1.67
--- test_unicode.py	23 Aug 2002 18:50:21 -0000	1.68
***************
*** 214,217 ****
--- 214,219 ----
  test('replace', u'abc', u'-a-b-c', u'', u'-', 3)
  test('replace', u'abc', u'abc', u'', u'-', 0)
+ test('replace', u'abc', u'abc', u'ab', u'--', 0)
+ test('replace', u'abc', u'abc', u'xy', u'--')
  test('replace', u'', u'', u'', u'')