From 4e5e1bf23186917d02fba903df19f2410c72ed62 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 7 Mar 2018 21:48:51 +0100 Subject: [PATCH] [BEAM-1251] Upgrade from buffer to memoryview for Python 3 --- sdks/python/apache_beam/io/avroio.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdks/python/apache_beam/io/avroio.py b/sdks/python/apache_beam/io/avroio.py index 30fc8903283cf..78e2bfb483944 100644 --- a/sdks/python/apache_beam/io/avroio.py +++ b/sdks/python/apache_beam/io/avroio.py @@ -52,6 +52,8 @@ from avro import datafile from avro import schema +from six import binary_type + import apache_beam as beam from apache_beam.io import filebasedsink from apache_beam.io import filebasedsource @@ -309,8 +311,8 @@ def _decompress_bytes(data, codec): # Compressed data includes a 4-byte CRC32 checksum which we verify. # We take care to avoid extra copies of data while slicing large objects - # by use of a buffer. - result = snappy.decompress(buffer(data)[:-4]) + # by use of a memoryview. + result = snappy.decompress(binary_type(memoryview(data)[:-4])) avroio.BinaryDecoder(cStringIO.StringIO(data[-4:])).check_crc32(result) return result else: