summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unicode.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-02-07 22:12:46 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-02-07 22:12:46 (GMT)
commitbbbac2ec34e99c24d7bc0eedbcc138c5f4551d48 (patch)
treed78b2fead0311d37b6f76d0a3466fd78196c8c31 /Lib/test/test_unicode.py
parent2efdc90b0f49866d857a5b3dc21b7c791f7a0aeb (diff)
downloadcpython-bbbac2ec34e99c24d7bc0eedbcc138c5f4551d48.zip
cpython-bbbac2ec34e99c24d7bc0eedbcc138c5f4551d48.tar.gz
cpython-bbbac2ec34e99c24d7bc0eedbcc138c5f4551d48.tar.bz2
Issue #17137: When an Unicode string is resized, the internal wide character
string (wstr) format is now cleared.
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r--Lib/test/test_unicode.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 8fccab3..f7d8686 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -2167,6 +2167,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):