diff --git a/CHANGES.txt b/CHANGES.txt index 201ff167d0d..3ee354b3a8b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,9 @@ Avro 1.3.3 (Unreleased) AVRO-560. Python impl should include system errors in every protocol (hammer) + AVRO-559. Handle read_union error where the list index of the union branch + to follow exceeds the size of the union schema (hammer) + BUG FIXES AVRO-496. python sample_http_client.py is broken (Jeff Hodges via hammer) diff --git a/lang/py/src/avro/io.py b/lang/py/src/avro/io.py index ff2ba24faf9..55e15639b17 100644 --- a/lang/py/src/avro/io.py +++ b/lang/py/src/avro/io.py @@ -606,6 +606,10 @@ def read_union(self, writers_schema, readers_schema, decoder): """ # schema resolution index_of_schema = int(decoder.read_long()) + if index_of_schema >= len(writers_schema.schemas): + fail_msg = "Can't access branch index %d for union with %d branches"\ + % (index_of_schema, writers_schema.schemas) + raise SchemaResolutionException(fail_msg, writers_schema, readers_schema) selected_writers_schema = writers_schema.schemas[index_of_schema] # read data