[Python-checkins] python/dist/src/Lib/test test_codeccallbacks.py,
1.12.8.1, 1.12.8.2
doerwalter at users.sourceforge.net
doerwalter at users.sourceforge.net
Fri Oct 24 11:05:31 EDT 2003
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv28564/Lib/test
Modified Files:
Tag: release23-maint
test_codeccallbacks.py
Log Message:
Backport checkin:
Fix a bug in the memory reallocation code of PyUnicode_TranslateCharmap().
charmaptranslate_makespace() allocates more memory than required for the
next replacement but didn't remember that fact, so memory size was growing
exponentially every time a replacement string is longer that one character.
This fixes SF bug #828737.
Index: test_codeccallbacks.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codeccallbacks.py,v
retrieving revision 1.12.8.1
retrieving revision 1.12.8.2
diff -C2 -d -r1.12.8.1 -r1.12.8.2
*** test_codeccallbacks.py 12 Aug 2003 17:38:22 -0000 1.12.8.1
--- test_codeccallbacks.py 24 Oct 2003 15:05:29 -0000 1.12.8.2
***************
*** 691,694 ****
--- 691,706 ----
self.assertRaises(TypeError, u"\xff".translate, {0xff: ()})
+ def test_bug828737(self):
+ charmap = {
+ ord("&"): u"&",
+ ord("<"): u"<",
+ ord(">"): u">",
+ ord('"'): u""",
+ }
+
+ for n in (1, 10, 100, 1000):
+ text = u'abc<def>ghi'*n
+ text.translate(charmap)
+
def test_main():
test.test_support.run_unittest(CodecCallbackTest)
More information about the Python-checkins
mailing list