summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-28 09:54:22 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-28 09:54:22 +0200
commit9ae14e605a9b8d6a25a7e2640ef91a499ae479ad (patch)
tree743d5fd8fef0a79ba7dfd13f9fee4246534398e6 /Lib
parent90bb1052d6d3c6f33da99228af072b27e700a3f6 (diff)
downloadcpython-9ae14e605a9b8d6a25a7e2640ef91a499ae479ad.tar.gz
Issue #29073: bytearray formatting no longer truncates on first null byte.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_format.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index 0e83a69bff..565bb79d7e 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -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")