diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-02-07 22:17:34 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-02-07 22:17:34 (GMT) |
commit | cfd2c1b4ccb4355a914c7e4084141d522ada8666 (patch) | |
tree | 76c283a1452f58ef816f3695778119f82b512443 /Lib/test | |
parent | eae3b3331607fcf0ac888aa2f1e34c19fe2f0a7f (diff) | |
parent | bbbac2ec34e99c24d7bc0eedbcc138c5f4551d48 (diff) | |
download | cpython-cfd2c1b4ccb4355a914c7e4084141d522ada8666.zip cpython-cfd2c1b4ccb4355a914c7e4084141d522ada8666.tar.gz cpython-cfd2c1b4ccb4355a914c7e4084141d522ada8666.tar.bz2 |
(Merge 3.3) Issue #17137: When an Unicode string is resized, the internal wide
character string (wstr) format is now cleared.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_unicode.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 2d42aac..b5e0887 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -2191,6 +2191,21 @@ class UnicodeTest(string_tests.CommonTest, self.assertEqual(args[0], text) self.assertEqual(len(args), 1) + def test_resize(self): + for length in range(1, 100, 7): + # generate a fresh string (refcount=1) + text = 'a' * length + 'b' + + # fill wstr internal field + abc = text.encode('unicode_internal') + self.assertEqual(abc.decode('unicode_internal'), text) + + # resize text: wstr field must be cleared and then recomputed + text += 'c' + abcdef = text.encode('unicode_internal') + self.assertNotEqual(abc, abcdef) + self.assertEqual(abcdef.decode('unicode_internal'), text) + class StringModuleTest(unittest.TestCase): def test_formatter_parser(self): |