8000 [3.6] bpo-29714: Fix a regression that bytes format may fail when containing zero bytes inside. by zhangyangyu · Pull Request #504 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.6] bpo-29714: Fix a regression that bytes format may fail when containing zero bytes inside. #504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-29714: Fix a regression that bytes format may fail when containin…
…g zero bytes inside. (GH-499)
  • Loading branch information
zhangyangyu committed Mar 6, 2017
commit 43463b62cf239b0ae41b419a50ddd877c282828c
10 changes: 10 additions & 0 deletions Lib/test/test_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,11 @@ def test_mod(self):
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!')
Expand All @@ -519,6 +524,11 @@ def test_imod(self):
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):
Expand Down
Loading
0