diff options
author | Xiang Zhang <angwerzx@126.com> | 2017-03-06 09:17:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-06 09:17:05 (GMT) |
commit | b76ad5121e2cfa89d6476d700cbcb65b7ffc39ac (patch) | |
tree | fd9ddcebff7e19fd07c62675dbdd5cceccd7963f /Lib/test | |
parent | 86aa269646fa73bbcbc26f45ed854359d04c1fde (diff) | |
download | cpython-b76ad5121e2cfa89d6476d700cbcb65b7ffc39ac.zip cpython-b76ad5121e2cfa89d6476d700cbcb65b7ffc39ac.tar.gz cpython-b76ad5121e2cfa89d6476d700cbcb65b7ffc39ac.tar.bz2 |
bpo-29714: Fix a regression that bytes format may fail when containing zero bytes inside. (GH-499)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_bytes.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py index 671c35e..8a3b805 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -515,6 +515,11 @@ class BaseBytesTest: a = b % (b'seventy-nine', 79) self.assertEqual(a, b'seventy-nine / 100 = 79%') self.assertIs(type(a), self.type2test) + # issue 29714 + b = self.type2test(b'hello,\x00%b!') + b = b % b'world' + self.assertEqual(b, b'hello,\x00world!') + self.assertIs(type(b), self.type2test) def test_imod(self): b = self.type2test(b'hello, %b!') @@ -527,6 +532,11 @@ class BaseBytesTest: b %= (b'seventy-nine', 79) self.assertEqual(b, b'seventy-nine / 100 = 79%') self.assertIs(type(b), self.type2test) + # issue 29714 + b = self.type2test(b'hello,\x00%b!') + b %= b'world' + self.assertEqual(b, b'hello,\x00world!') + self.assertIs(type(b), self.type2test) def test_rmod(self): with self.assertRaises(TypeError): |