mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #12380: PyArg_ParseTuple now accepts a bytearray for the 'c' format.
As a side effect, this now allows the rjust, ljust and center methods of bytes and bytearray to accept a bytearray argument. Patch by Petri Lehtinen
This commit is contained in:
parent
66d2be8986
commit
906b88fb2a
6 changed files with 53 additions and 4 deletions
|
@ -475,6 +475,27 @@ class BaseBytesTest(unittest.TestCase):
|
|||
self.assertRaises(TypeError, self.type2test(b'abc').lstrip, 'b')
|
||||
self.assertRaises(TypeError, self.type2test(b'abc').rstrip, 'b')
|
||||
|
||||
def test_center(self):
|
||||
# Fill character can be either bytes or bytearray (issue 12380)
|
||||
b = self.type2test(b'abc')
|
||||
for fill_type in (bytes, bytearray):
|
||||
self.assertEqual(b.center(7, fill_type(b'-')),
|
||||
self.type2test(b'--abc--'))
|
||||
|
||||
def test_ljust(self):
|
||||
# Fill character can be either bytes or bytearray (issue 12380)
|
||||
b = self.type2test(b'abc')
|
||||
for fill_type in (bytes, bytearray):
|
||||
self.assertEqual(b.ljust(7, fill_type(b'-')),
|
||||
self.type2test(b'abc----'))
|
||||
|
||||
def test_rjust(self):
|
||||
# Fill character can be either bytes or bytearray (issue 12380)
|
||||
b = self.type2test(b'abc')
|
||||
for fill_type in (bytes, bytearray):
|
||||
self.assertEqual(b.rjust(7, fill_type(b'-')),
|
||||
self.type2test(b'----abc'))
|
||||
|
||||
def test_ord(self):
|
||||
b = self.type2test(b'\0A\x7f\x80\xff')
|
||||
self.assertEqual([ord(b[i:i+1]) for i in range(len(b))],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue