mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-44439: _ZipWriteFile.write() handle buffer protocol correctly (GH-29468)
Co-authored-by: Marco Ribeiro <marcoffee@users.noreply.github.com>
This commit is contained in:
parent
591f6754b5
commit
36dd7396fc
3 changed files with 19 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
import array
|
||||
import contextlib
|
||||
import importlib.util
|
||||
import io
|
||||
|
@ -1121,6 +1122,14 @@ class AbstractWriterTests:
|
|||
self.assertRaises(ValueError, w.write, b'')
|
||||
self.assertEqual(zipf.read('test'), data)
|
||||
|
||||
def test_issue44439(self):
|
||||
q = array.array('Q', [1, 2, 3, 4, 5])
|
||||
LENGTH = len(q) * q.itemsize
|
||||
with zipfile.ZipFile(io.BytesIO(), 'w', self.compression) as zip:
|
||||
with zip.open('data', 'w') as data:
|
||||
self.assertEqual(data.write(q), LENGTH)
|
||||
self.assertEqual(zip.getinfo('data').file_size, LENGTH)
|
||||
|
||||
class StoredWriterTests(AbstractWriterTests, unittest.TestCase):
|
||||
compression = zipfile.ZIP_STORED
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue