Issue #29073: bytearray formatting no longer truncates on first null byte.

This commit is contained in:
Serhiy Storchaka 2016-12-28 09:54:22 +02:00
parent af9181a4f2
commit c9ad8b7a23
3 changed files with 12 additions and 1 deletions

View file

@ -388,6 +388,13 @@ class FormatTest(unittest.TestCase):
else:
raise TestFailed('"%*d"%(maxsize, -127) should fail')
def test_nul(self):
# test the null character
testcommon("a\0b", (), 'a\0b')
testcommon("a%cb", (0,), 'a\0b')
testformat("a%sb", ('c\0d',), 'ac\0db')
testcommon(b"a%sb", (b'c\0d',), b'ac\0db')
def test_non_ascii(self):
testformat("\u20ac=%f", (1.0,), "\u20ac=1.000000")