AVRO-1741: Py3: Fix error when codec is not in the header. Contributed by Matthew Hayes.
This happens when the compression codec is None, meaning the
"null"/uncompressed codec.
diff --git a/CHANGES.txt b/CHANGES.txt
index 020b523..37ff25c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -12,6 +12,9 @@
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
diff --git a/lang/py3/avro/datafile.py b/lang/py3/avro/datafile.py
index fc93fe1..7894d79 100644
--- a/lang/py3/avro/datafile.py
+++ b/lang/py3/avro/datafile.py
@@ -349,9 +349,11 @@
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)