Skip to content

Commit

Permalink
AVRO-1741: Py3: Fix error when codec is not in the header. Contribute…
Browse files Browse the repository at this point in the history
…d by Matthew Hayes.

This happens when the compression codec is None, meaning the
"null"/uncompressed codec.
  • Loading branch information
rdblue committed Jun 2, 2016
1 parent ae3b78f commit 191badb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Trunk (not yet released)

BUG FIXES

AVRO-1741: Python3: Fix error when codec is not in the header.
(Matthew Hayes via blue)

Avro 1.8.1 (14 May 2016)

INCOMPATIBLE CHANGES
Expand Down
6 changes: 4 additions & 2 deletions lang/py3/avro/datafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,11 @@ def __init__(self, reader, datum_reader):
self._read_header()

# ensure codec is valid
self.codec = self.GetMeta('avro.codec').decode('utf-8')
if self.codec is None:
avro_codec_raw = self.GetMeta('avro.codec')
if avro_codec_raw is None:
self.codec = "null"
else:
self.codec = avro_codec_raw.decode('utf-8')
if self.codec not in VALID_CODECS:
raise DataFileException('Unknown codec: %s.' % self.codec)

Expand Down

0 comments on commit 191badb

Please sign in to comment.