Serhiy Storchaka added the comment:
Here is a patch that restores support on non-contiguous memoryviews.
It would be better to drop support of non-contiguous data, because it worked
only by accident. Needed support of only bytes-like memoryviews written by
BufferedWriter.
----------
Added file: http://bugs.python.org/file38656/gzip_write_noncontiguous.patch
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23688>
_______________________________________
diff -r 7e179ee91af0 Lib/gzip.py
--- a/Lib/gzip.py Mon Mar 23 15:26:49 2015 +0200
+++ b/Lib/gzip.py Mon Mar 23 16:27:08 2015 +0200
@@ -340,6 +340,8 @@ class GzipFile(io.BufferedIOBase):
# accept any data that supports the buffer protocol
data = memoryview(data)
length = data.nbytes
+ if not data.contiguous:
+ data = bytes(data)
if length > 0:
self.fileobj.write(self.compress.compress(data))
diff -r 7e179ee91af0 Lib/test/test_gzip.py
--- a/Lib/test/test_gzip.py Mon Mar 23 15:26:49 2015 +0200
+++ b/Lib/test/test_gzip.py Mon Mar 23 16:27:08 2015 +0200
@@ -74,6 +74,7 @@ class TestGzip(BaseTest):
m = memoryview(bytes(range(256)))
data = m.cast('B', shape=[8,8,4])
self.write_and_read_back(data)
+ self.write_and_read_back(memoryview(data1 * 50)[::-1])
def test_write_bytearray(self):
self.write_and_read_back(bytearray(data1 * 50))
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com