py34 calling __eq__ for !=

Bug #1469864 reported by Thang Pham
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.versionedobjects
Fix Released
High
Thang Pham

Bug Description

There seems to be a problem in python 3.4 with the mix-in class ComparableVersionedObject.

harlowja found that in python 3.4, if an object is None or "a string" or something other than an oslo_versionedobject and it is compared to an versionedobject, the __eq__ compare method will be called. This will fail because the None.obj_to_primitive() is not a valid attribute.

This was found in a patch http://logs.openstack.org/54/177054/40/check/gate-cinder-python34/5bcd306/console.html#_2015-06-29_16_33_17_810, which failed in python 3.4 but passed in python 2.7. There appears to be some difference on when __eq__ is called and when it is not in python 3.4 vs. 2.7.

Take for example,

class Thingee(object):

  def __eq__(self, obj):
    print 'thingee eq called with %s' % obj
    return False

a = Thingee()
print a == None
print a != None

In python 2.7, the results are:
thingee eq called with None
False
True

In python 3.4, the results are:
thingee eq called with None
False
thingee eq called with None
True

In python 3.4, != calls __eq__.

Thang Pham (thang-pham)
description: updated
Changed in oslo.versionedobjects:
importance: Undecided → High
status: New → Confirmed
assignee: nobody → Davanum Srinivas (DIMS) (dims-v)
Changed in oslo.versionedobjects:
assignee: Davanum Srinivas (DIMS) (dims-v) → nobody
Revision history for this message
Thang Pham (thang-pham) wrote :
Changed in oslo.versionedobjects:
assignee: nobody → Thang Pham (thang-pham)
Changed in oslo.versionedobjects:
status: Confirmed → In Progress
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/oslo.versionedobjects 1.10.0

This issue was fixed in the openstack/oslo.versionedobjects 1.10.0 release.

Revision history for this message
Ben Nemec (bnemec) wrote :

Marking fix released per the last comment.

Changed in oslo.versionedobjects:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.