diff options
author | Xiang Zhang <angwerzx@126.com> | 2017-03-06 10:17:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-06 10:17:10 (GMT) |
commit | df6d7b406f3d1b2e4e2014751bfa25574c4df222 (patch) | |
tree | 17be021c71e543c71a5e2e21e929d481c096fd2d /Lib/test | |
parent | 4e1a065c20856a00d0fe88ce022b249170608058 (diff) | |
download | cpython-df6d7b406f3d1b2e4e2014751bfa25574c4df222.zip cpython-df6d7b406f3d1b2e4e2014751bfa25574c4df222.tar.gz cpython-df6d7b406f3d1b2e4e2014751bfa25574c4df222.tar.bz2 |
[3.6] bpo-29714: Fix a regression that bytes format may fail when containing zero bytes inside. (GH-504)
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 a103a7d..cd82fa6 100644 --- a/Lib/test/test_bytes.py +++ b/Lib/test/test_bytes.py @@ -507,6 +507,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!') @@ -519,6 +524,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): |