mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #17137: When an Unicode string is resized, the internal wide character
string (wstr) format is now cleared.
This commit is contained in:
parent
2efdc90b0f
commit
bbbac2ec34
3 changed files with 22 additions and 0 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue