GNOME Bugzilla – Bug 435825
Non-ORBit object typecodes ignored when instantiating stubs
Last modified: 2007-07-17 18:21:39 UTC
Reproducing this bug is difficult unless you have the AT-SPI/Java bridge for GNOME up and running. I'll try to give you as much information as possible here. When querying gtk using AT-SPI, we get a result with a proper interface on it already. For instance, if "d" is the desktop accessible: >>> d.getChildAtIndex(0) <CORBA.Object 'IDL:Accessibility/Application:1.0' at 0x8d06608> When querying a Java, we always initially get an object that appears to be null: >>> d.getChildAtIndex(1) <CORBA.Object '(null)' at 0x95158b0> On inspection of this object, it certainly is just a dummy CORBA object: >>> j = d.getChildAtIndex(1) >>> dir(j) ['__class__', '__cmp__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__typecode__', '_duplicate', '_hash', '_is_a', '_is_equivalent', '_is_nil', '_narrow', '_non_existent'] But watch what happens when I invoke _narrow explicitly giving it Accessibility.Application interface: >>> k = j._narrow(Accessibility.Application) >>> k <CORBA.Object '(null)' at 0x95158b0> Still looks dead, right? But guess what: >>> dir(k) ['__class__', '__cmp__', '__del__', '__delattr__', '__doc__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__iter__', '__len__', '__module__', '__new__', '__nonzero__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__slots__', '__str__', '__typecode__', '_duplicate', '_get_childCount', '_get_description', '_get_id', '_get_name', '_get_parent', '_get_toolkitName', '_get_version', '_hash', '_icache', '_is_a', '_is_equivalent', '_is_nil', '_mix___new__', '_mix___str__', '_mix_description', '_mix_getApplication', '_mix_getIndexInParent', '_mix_getRoleName', '_mix_name', '_narrow', '_non_existent', '_set_description', '_set_id', '_set_name', 'childCount', 'description', 'getApplication', 'getAttributes', 'getChildAtIndex', 'getIndexInParent', 'getLocale', 'getLocalizedRoleName', 'getRelationSet', 'getRole', 'getRoleName', 'getState', 'id', 'isEqual', 'name', 'parent', 'pause', 'ref', 'registerObjectEventListener', 'registerToolkitEventListener', 'resume', 'toolkitName', 'unImplemented2_', 'unImplemented3_', 'unImplemented_', 'unimplemented', 'unref', 'version'] >>> k.name 'Notepad' Now it's a truly functioning Application object. Why doesn't pyorbit properly narrow to the correct interface like it does for other toolkits? Is this a bug in pyorbit or Java?
Object introspection is an ORBit extension, not a general CORBA feature. Java has its own ORB, not ORBit, as far as I know.
I see. So the problem would have to be resolved in the Java bridge. Are we assured that the _narrow method in pyorbit will always be available for us to correct this problem on the client side? That _ makes it look protected, like it might vanish some day.
Re-opened after chat on IRC with Gustavo. Probably a bug in pycorba-object.c
<gjc> in pycorba_object_new: stub = (PyTypeObject *)pyorbit_get_stub_from_objref(objref); if (!stub) stub = &PyCORBA_Object_Type; /* fall back */ it is falling back in this case :) <parente> does the typecode provide enough info to build the right kind of object? <gjc> PyObject * pyorbit_get_stub(CORBA_TypeCode tc) <gjc> you have to pass the typecode into pycorba_object_new and call that function
Working on a patch.
Created attachment 87548 [details] [review] checks TypeCode to find stub Adds a TypeCode parameter to pycorba_object_new so a stub can be found for non-ORBit objects. Confirmed that it works with the Java 1.4.2 AT-SPI bridge on FC6. The repr() method still indicates the object is null with this patch because the call to ORBit_small_get_type fails to retrieve the object name. I don't know what other method to use besides this one for general CORBA objects. If such a function does not exist, a fix that should always work would be to look at the __typecode__.repo_id on the Python object passed to the pycorba_object_repr function. I'll file that as a separate bug.
This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.
Will the addition of the new CORBA_TypeCode parameter to pycorba_object_new() cause a binary compatibility issue?
No because the patch that was committed was not exactly the patch provided by Peter Parente; I tweaked it slightly in order to preserve API/ABI.
Could you please update the patch so that it may be back ported to released systems being maintained? Thanks.
You can get it from here: http://svn.gnome.org/viewcvs/pyorbit?view=revision&revision=150 Well, sort of.. you just need to concatenate the partial patches of each of the files :)
And I don't see why you would need it anyway; we make stable releases for a reason :|