Apache OpenOffice (AOO) Bugzilla – Issue 124953
[PyUNO] Add __ne__ method to UNO types
Last modified: 2019-03-09 21:46:18 UTC
If user defined class does not have __eq__ method, (a == b) is identification check of these instances. If __eq__ is defined, the customized identical comparizon can be done. If __ne__ method is not defined in the same class, (a != b) comparizon is still identical comparizon of the instances. uno.Enum is used to describe one of enum constants from UNO. So Enum.__eq__ method is returns True if typename and value are the same. But Enum.__ne__ is not defined and so, the result of the comparizon with an value instantiated other place by != operator returns True. Because these are not the same instance. uno.Enum, Type, Char, ByteSequence classes have to have __ne__ method. And also _uno_struct__eq__ method for UNO struct should be defined.
If someone use != operator for identification check, the code would break. Maybe the next major update is the chance to introduce the change.
Created attachment 83450 [details] Patch to add __ne__ method to some classes The patch contains __ne__ methods for Enum, Type, Char, ByteSequence and structs.
Created attachment 83451 [details] Test file that contains unittest case Execute "run" procedure as Python macro to execute the test case. self.assertFalse call method fails in all five tests on current implementation of uno.py. With the attached patch, all tests should be passed.
This kind of changes might give different behavior for user's scripts. Should be applied when major update is planned, maybe version 5.
Set as PATCH