Closed
Bug 492891
Opened 17 years ago
Closed 15 years ago
pyxpcom: comparison between Python xpcom objects can differ when retrieved through an array
Categories
(Other Applications Graveyard :: PyXPCOM, defect)
Tracking
(Not tracked)
RESOLVED
DUPLICATE
of bug 196653
People
(Reporter: twhitema, Unassigned)
Details
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.10) Gecko/2009042513 Ubuntu/8.04 (hardy) Firefox/3.0.10
Build Identifier: Mozilla 1.9.0
Returning an xpcom instance through an XPCOM array result creates a different Python object to the original xpcom instance that was originally added to the array (different in a Python comparison '==' test).
Reproducible: Always
Steps to Reproduce:
Given the following IDL:
[scriptable, uuid(f6f21a78-d510-45ab-8632-68ad561988e6)]
interface toddTestInstance: nsISupports
{
attribute wstring name;
};
[scriptable, uuid(b5a7077d-df2c-424b-a178-09b7e55d193a)]
interface toddTestService: nsISupports
{
toddTestInstance makeInstanceFromName(in wstring name);
toddTestInstance getFirstInstance();
void getAllInstances([array, size_is(count)] out toddTestInstance instances,
out PRUint32 count);
};
Implemented in Python as:
class toddTestInstance:
_com_interfaces_ = [components.interfaces.toddTestInstance]
_reg_desc_ = "Test Instance"
_reg_contractid_ = "@todd.com/toddTestInstance;1"
_reg_clsid_ = "{4089e748-70b7-43a7-8ea3-d320577e2a13}"
def __init__(self, name=None):
self.name = name or ""
class toddTestService:
_com_interfaces_ = [components.interfaces.toddTestService]
_reg_desc_ = "Test Instance"
_reg_contractid_ = "@todd.com/toddTestService;1"
_reg_clsid_ = "{828986bd-0476-410a-b508-986e9a1286a0}"
def __init__(self):
self.__instances = []
def makeInstanceFromName(self, name):
inst = components.classes["@todd.com/toddTestInstance;1"].\
createInstance(components.interfaces.toddTestInstance)
inst.name = name
self.__instances.append(inst)
return inst
def getFirstInstance(self):
if self.__instances:
return self.__instances[0]
return None
def getAllInstances(self):
return self.__instances
The object comparison results are:
tSvc = components.classes["@todd.com/toddTestService;1"].\
getService(components.interfaces.toddTestService)
t1 = tSvc.makeInstanceFromName("todd")
t2 = tSvc.getFirstInstance()
all = tSvc.getAllInstances()
t3 = all[0]
print t1 == t2 # True, all good here.
print t1 == t3 # False, wtf?
print t2 == t3 # False, wtf?
print t1
# <XPCOM component '@todd.com/toddTestInstance;1' (implementing toddTestInstance)>
print t2
# <XPCOM component '@todd.com/toddTestInstance;1' (implementing toddTestInstance)>
print t3
# <XPCOM component '@todd.com/toddTestInstance;1' (implementing )>
# Let's try QI then
t3 = t3.QueryInterface(components.interfaces.toddTestInstance)
print t3
# <XPCOM component '@todd.com/toddTestInstance;1' (implementing toddTestInstance)>
# Okay, even looks the same now, lets see:
print t1 == t3 # False, wtf?
# Hrmmm.... what's different then... interfaces?
print t1._interface_names_
# {'toddTestInstance': <XPCOM interface 'toddTestInstance'>}
print t3._interface_names_
# {'toddTestInstance': <XPCOM interface 'toddTestInstance'>, 'nsISupports': <XPCOM interface 'nsISupports'>}
| Reporter | ||
Updated•17 years ago
|
Version: unspecified → 1.9.0 Branch
| Reporter | ||
Comment 1•17 years ago
|
||
I imagine this bug also exists in 1.9.1 and higher (though I have not test it there), as pyxpcom does not change much.
c.f. This bug is also logged at ActiveState (Komodo):
http://bugs.activestate.com/show_bug.cgi?id=83120
Updated•17 years ago
|
Component: XPCOM → PyXPCOM
Product: Core → Other Applications
QA Contact: xpcom → pyxpcom
Version: 1.9.0 Branch → unspecified
| Reporter | ||
Updated•15 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → DUPLICATE
Updated•8 years ago
|
Product: Other Applications → Other Applications Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•