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

ASF subversion and git services commented on AVRO-3104:
-------------------------------------------------------

Commit 72a0fef3e9247bd94621288fb2e6d88408e3c836 in avro's branch 
refs/heads/master from Michael A. Smith
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=72a0fef ]

AVRO-3104 Allow Comparing Schemas to non-Schemas (#1221)

Avro no longer crashes with an `AttributeError` when you test if a schema is 
equal to an object that is not a schema, as in `some_schema == not_a_schema`. 
The result is always `False`.

> avro-python __eq__ method of PrimitiveSchema, EnumSchema and FixedSchema 
> throws exception
> -----------------------------------------------------------------------------------------
>
>                 Key: AVRO-3104
>                 URL: https://issues.apache.org/jira/browse/AVRO-3104
>             Project: Apache Avro
>          Issue Type: Bug
>          Components: python
>    Affects Versions: 1.10.2
>            Reporter: Thomas Larsson
>            Priority: Minor
>         Attachments: AVRO-3104.patch
>
>
> The __eq__ method of the 
> [PrimitiveSchema|https://github.com/apache/avro/blob/master/lang/py3/avro/schema.py#L629],
>  EnumSchema and FixedSchema assume that the compared object has an attribute 
> called "props" which makes a statement like this (for example) throw an 
> exception:
> {code:python}
> o = PrimitiveSchema(...)
> if o == "null":
>   print("Not same")
> {code}
>    
> The exception message looks like:
> {code:bash}
> AttributeError: 'str' object has no attribute 'props'
> {code}
> A more robust equals method would start by ensuring type equality before 
> doing other comparisons. Alternatively (though less pretty) the way the other 
> Schema types implement it could be used, for example 
> [ArraySchema|https://github.com/apache/avro/blob/master/lang/py3/avro/schema.py#L772]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to