[omniORB] EnumItem problems in omniORBpy2.3
Duncan Grisby
duncan at grisby.org
Wed Feb 11 11:03:30 GMT 2004
On Tuesday 10 February, Jakub Moscicki wrote:
> >>> DIANE_CORBA.ok == None
[...]
> AttributeError: 'NoneType' object has no attribute '_v'
[...]
> Question: is this new behavior intentional or a bug?
It's a bug. I've fixed it in CVS, or you can use the following patch.
The new __cmp__ code is to allow enum items to be compared with each
other. Unfortunately, it broke other comparisons.
As a general Python style suggestions, it's a good idea to do
comparisons with None using "is", rather than "==":
DIANE_CORBA.ok is None
That way you don't get bitten by things like this __cmp__ bug.
Cheers,
Duncan.
--- python/omniORB/__init__.py 19 Nov 2003 14:23:42 -0000 1.26.2.19
+++ python/omniORB/__init__.py 11 Feb 2004 10:56:00 -0000
@@ -478,7 +478,16 @@
return self._n
def __cmp__(self, other):
- return cmp(self._v, other._v)
+ try:
+ if isinstance(other, EnumItem):
+ if other._parent_id == self._parent_id:
+ return cmp(self._v, other._v)
+ else:
+ return cmp(self._parent_id, other._parent_id)
+ else:
+ return cmp(id(self), id(other))
+ except:
+ return cmp(id(self), id(other))
def __hash__(self):
return id(self)
--
-- Duncan Grisby --
-- duncan at grisby.org --
-- http://www.grisby.org --
More information about the omniORB-list
mailing list