summaryrefslogtreecommitdiff
path: root/Lib/test/test_codeccallbacks.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2003-10-24 14:25:28 +0000
committerWalter Dörwald <walter@livinglogic.de>2003-10-24 14:25:28 +0000
commit4f3f6e2d5ae04ae68b1ac90769da95068c51534b (patch)
tree32e577fda35f5cc1251b53ca21677640e03e84f5 /Lib/test/test_codeccallbacks.py
parentf934c612d6c506a78eb5cf950482536c010b06c9 (diff)
downloadcpython-4f3f6e2d5ae04ae68b1ac90769da95068c51534b.tar.gz
Fix a bug in the memory reallocation code of PyUnicode_TranslateCharmap().
charmaptranslate_makespace() allocated 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.
Diffstat (limited to 'Lib/test/test_codeccallbacks.py')
-rw-r--r--Lib/test/test_codeccallbacks.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py
index ae75229d86..289e838b58 100644
--- a/Lib/test/test_codeccallbacks.py
+++ b/Lib/test/test_codeccallbacks.py
@@ -690,6 +690,18 @@ class CodecCallbackTest(unittest.TestCase):
self.assertRaises(TypeError, u"\xff".translate, {0xff: sys.maxunicode+1})
self.assertRaises(TypeError, u"\xff".translate, {0xff: ()})
+ def test_bug828737(self):
+ charmap = {
+ ord("&"): u"&amp;",
+ ord("<"): u"&lt;",
+ ord(">"): u"&gt;",
+ ord('"'): u"&quot;",
+ }
+
+ 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)