diff --git a/sdks/python/apache_beam/io/avroio.py b/sdks/python/apache_beam/io/avroio.py index 30fc8903283c..78e2bfb48394 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: