changeset: 105865:9b77e3a586b0 branch: 3.6 parent: 105860:e44b6b01c8cf parent: 105864:277b36596a54 user: Serhiy Storchaka date: Wed Dec 28 09:56:52 2016 +0200 files: Lib/test/test_format.py Misc/NEWS Objects/bytearrayobject.c description: Issue #29073: Added a test for bytearray formatting with null byte. diff -r e44b6b01c8cf -r 9b77e3a586b0 Lib/test/test_format.py --- a/Lib/test/test_format.py Wed Dec 28 09:19:45 2016 +0200 +++ b/Lib/test/test_format.py Wed Dec 28 09:56:52 2016 +0200 @@ -390,6 +390,13 @@ 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")