Matthew Hayes created AVRO-1741:
-----------------------------------
Summary: Python 3 code should check if avro.codec is None before
decoding
Key: AVRO-1741
URL: https://issues.apache.org/jira/browse/AVRO-1741
Project: Avro
Issue Type: Bug
Reporter: Matthew Hayes
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.
{code}
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'
{code}
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.
{code}
# 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)
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)