Issue 124953 - [PyUNO] Add __ne__ method to UNO types
Summary: [PyUNO] Add __ne__ method to UNO types
Status: CONFIRMED
Alias: None
Product: App Dev
Classification: Unclassified
Component: scripting (show other issues)
Version: 4.1.0
Hardware: All All
: P3 Normal
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-21 16:22 UTC by hanya
Modified: 2019-03-09 21:46 UTC (History)
1 user (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Patch to add __ne__ method to some classes (2.76 KB, patch)
2014-05-22 17:17 UTC, hanya
no flags Details | Diff
Test file that contains unittest case (4.66 KB, text/x-python)
2014-05-22 17:21 UTC, hanya
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description hanya 2014-05-21 16:22:07 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.
Comment 1 hanya 2014-05-21 16:29:37 UTC
If someone use != operator for identification check, the code would break. 
Maybe the next major update is the chance to introduce the change.
Comment 2 hanya 2014-05-22 17:17:43 UTC
Created attachment 83450 [details]
Patch to add __ne__ method to some classes

The patch contains __ne__ methods for Enum, Type, Char, ByteSequence and structs.
Comment 3 hanya 2014-05-22 17:21:25 UTC
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.
Comment 4 hanya 2014-10-24 16:21:22 UTC
This kind of changes might give different behavior for user's scripts. 
Should be applied when major update is planned, maybe version 5.
Comment 5 oooforum (fr) 2019-03-09 21:46:18 UTC
Set as PATCH