8000 bpo-29714: Fix a regression that bytes format may fail when containi… · zhangyangyu/cpython@43463b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 43463b6

Browse files
committed
bpo-29714: Fix a regression that bytes format may fail when containing zero bytes inside. (p 10000 ythonGH-499)
1 parent 4e1a065 commit 43463b6

File tree

3 files changed

+789
-2
lines changed

3 files changed

+789
-2
lines changed

Lib/test/test_bytes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,11 @@ def test_mod(self):
507507
a = b % (b'seventy-nine', 79)
508508
self.assertEqual(a, b'seventy-nine / 100 = 79%')
509509
self.assertIs(type(a), self.type2test)
510+
# issue 29714
511+
b = self.type2test(b'hello,\x00%b!')
512+
b = b % b'world'
513+
self.assertEqual(b, b'hello,\x00world!')
514+
self.assertIs(type(b), self.type2test)
510515

511516
def test_imod(self):
512517
b = self.type2test(b'hello, %b!')
@@ -519,6 +524,11 @@ def test_imod(self):
519524
b %= (b'seventy-nine', 79)
520525
self.assertEqual(b, b'seventy-nine / 100 = 79%')
521526
self.assertIs(type(b), self.type2test)
527+
# issue 29714
528+
b = self.type2test(b'hello,\x00%b!')
529+
b %= b'world'
530+
self.assertEqual(b, b'hello,\x00world!')
531+
self.assertIs(type(b), self.type2test)
522532

523533
def test_rmod(self):
524534
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)
0