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))