Zoltan Fedor created AVRO-1737:
----------------------------------

             Summary: Python 3.4 - unhashable type: 'RecordSchema'
                 Key: AVRO-1737
                 URL: https://issues.apache.org/jira/browse/AVRO-1737
             Project: Avro
          Issue Type: Bug
          Components: python
    Affects Versions: 1.7.7
         Environment: Python 3.4, avro 1.7.7
            Reporter: Zoltan Fedor


Following the standard example from 
http://avro.apache.org/docs/current/gettingstartedpython.html but adding a 
dict.get() lookup using an avro.schema.RecordSchema object fails due to 
"unhashable type: 'RecordSchema'"

This likely happens because the RecordSchema class overwrite the __eq__ method 
but does NOT define a __hash__ method.

To reproduce run the following script in Python 3 (tested in Python 3.4.3):
import avro.schema
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumWriter

schema = avro.schema.Parse(open("users.avsc").read())

writer = DataFileWriter(open("users.avro", "wb"), DatumWriter(), schema)
writer.append({"name": "Alyssa", "favorite_number": 256})
writer.append({"name": "Ben", "favorite_number": 7, "favorite_color": "red"})
writer.close()

reader = DataFileReader(open("users.avro", "rb"), DatumReader())
for user in reader:
    print(user)
reader.close()

# added to generate the error
test = {}
test.get(schema, -1)




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to