You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Suraj Acharya (JIRA)" <ji...@apache.org> on 2017/07/25 19:14:00 UTC

[jira] [Commented] (AVRO-1741) Python 3 code should check if avro.codec is None before decoding

    [ https://issues.apache.org/jira/browse/AVRO-1741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16100583#comment-16100583 ] 

Suraj Acharya commented on AVRO-1741:
-------------------------------------

Seems like the patch has been merged.
Any reason this is still in Patch Available state?


> 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
>            Assignee: Matthew Hayes
>             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
(v6.4.14#64029)