mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Make zlib and zipimport to return bytes instead of bytearray and use bytes rather than bytearray for their internal leftover data storages.
This commit is contained in:
parent
35e661c711
commit
693fc4604f
4 changed files with 55 additions and 43 deletions
|
@ -110,6 +110,8 @@ class CompressObjectTestCase(unittest.TestCase):
|
|||
y1 = dco.decompress(x1 + x2)
|
||||
y2 = dco.flush()
|
||||
self.assertEqual(data, y1 + y2)
|
||||
self.assert_(isinstance(dco.unconsumed_tail, bytes))
|
||||
self.assert_(isinstance(dco.unused_data, bytes))
|
||||
|
||||
def test_compressoptions(self):
|
||||
# specify lots of options to compressobj()
|
||||
|
@ -152,7 +154,11 @@ class CompressObjectTestCase(unittest.TestCase):
|
|||
bufs.append(co.flush())
|
||||
combuf = b''.join(bufs)
|
||||
|
||||
self.assertEqual(data, zlib.decompress(combuf))
|
||||
decombuf = zlib.decompress(combuf)
|
||||
# Test type of return value
|
||||
self.assert_(isinstance(decombuf, bytes))
|
||||
|
||||
self.assertEqual(data, decombuf)
|
||||
|
||||
dco = zlib.decompressobj()
|
||||
bufs = []
|
||||
|
@ -348,6 +354,8 @@ class CompressObjectTestCase(unittest.TestCase):
|
|||
# Test copying a decompression object
|
||||
data = HAMLET_SCENE
|
||||
comp = zlib.compress(data)
|
||||
# Test type of return value
|
||||
self.assert_(isinstance(comp, bytes))
|
||||
|
||||
d0 = zlib.decompressobj()
|
||||
bufs0 = []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue