[ https://issues.apache.org/jira/browse/AVRO-1741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16726175#comment-16726175 ]
Anthony Hsu commented on AVRO-1741: ----------------------------------- This Jira can be resolved. The fix is committed [here|https://github.com/apache/avro/commit/191badb80281498611ffcbc0e79b9b020a3d5096#diff-4c24d0cfd2675026f0b87b9bfcaac54e] and present in avro-python3 1.8.2. > 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: Apache Avro > Issue Type: Bug > Reporter: Matthew Hayes > Assignee: Matthew Hayes > Priority: Major > Fix For: 1.7.7 > > Attachments: AVRO-1741.diff > > > 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 (v7.6.3#76005)