Description
I'm getting the error below when trying to read an Avro file in Python 3. FWIW, I generated this Avro file from Pig. I don't know if that makes a difference.
avro.datafile.DataFileReader(open("test.avro","rb"),avro.io.DatumReader()) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/mhayes/.pyenv/versions/3.4.2/lib/python3.4/site-packages/avro/datafile.py", line 352, in __init__ self.codec = self.GetMeta('avro.codec').decode('utf-8') AttributeError: 'NoneType' object has no attribute 'decode'
It appears the problem is in the following code. It should check if GetMeta returns None before trying to decode it. The Python 2 code doesn't have this problem because it is already decoded.
# ensure codec is valid self.codec = self.GetMeta('avro.codec').decode('utf-8') if self.codec is None: self.codec = "null" if self.codec not in VALID_CODECS: raise DataFileException('Unknown codec: %s.' % self.codec)