[Python] Improve model equality implementation (#4663)

* [Python] Improve model equality implementation

The model equality implementation template blindly tried accessing the
`__dict__` attribute of the variable to compare equality against. This
attribute does not exist for a lot of Python built-in types (`None`,
`str` etc.) and the equality check would simply crash.

This adds a simple guard to only continue with equality check if the
variable to compare is an instance of the model being compared against.

* Remove wrong auto-update of Python requirements
This commit is contained in:
Frode Danielsen
2017-01-27 17:42:53 +01:00
committed by wing328
parent 869374125f
commit 3236ade09d
37 changed files with 104 additions and 5 deletions

View File

@@ -172,6 +172,9 @@ class {{classname}}(object):
"""
Returns true if both objects are equal
"""
if not isinstance(other, {{classname}}):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other):