mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
bpo-44439: _ZipWriteFile.write() handle buffer protocol correctly (GH-29468)
Co-authored-by: Marco Ribeiro <marcoffee@users.noreply.github.com>
(cherry picked from commit 36dd7396fc)
Co-authored-by: Ma Lin <animalize@users.noreply.github.com>
This commit is contained in:
parent
89c360125b
commit
0663ca17f5
3 changed files with 19 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import array
|
||||
import contextlib
|
||||
import importlib.util
|
||||
import io
|
||||
|
|
@ -1117,6 +1118,14 @@ def test_write_after_close(self):
|
|||
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