After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 435825 - Non-ORBit object typecodes ignored when instantiating stubs
Non-ORBit object typecodes ignored when instantiating stubs
Status: RESOLVED FIXED
Product: pyorbit
Classification: Deprecated
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Peter Parente
Python bindings maintainers
Depends on:
Blocks: 440238
 
 
Reported: 2007-05-04 13:48 UTC by Peter Parente
Modified: 2007-07-17 18:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
checks TypeCode to find stub (3.83 KB, patch)
2007-05-04 17:06 UTC, Peter Parente
none Details | Review

Description Peter Parente 2007-05-04 13:48:17 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?
Comment 1 Gustavo Carneiro 2007-05-04 14:16:33 UTC
Object introspection is an ORBit extension, not a general CORBA feature.  Java has its own ORB, not ORBit, as far as I know.
Comment 2 Peter Parente 2007-05-04 14:28:24 UTC
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.
Comment 3 Peter Parente 2007-05-04 15:01:07 UTC
Re-opened after chat on IRC with Gustavo. Probably a bug in pycorba-object.c
Comment 4 Peter Parente 2007-05-04 15:09:38 UTC
<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
Comment 5 Peter Parente 2007-05-04 15:30:45 UTC
Working on a patch.
Comment 6 Peter Parente 2007-05-04 17:06:17 UTC
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.
Comment 7 Gustavo Carneiro 2007-05-06 11:15:16 UTC
This problem has been fixed in our software repository. The fix will go into the next software release. Thank you for your bug report.
Comment 8 George Kraft IV 2007-07-17 16:27:03 UTC
Will the addition of the new CORBA_TypeCode parameter to pycorba_object_new() cause a binary compatibility issue?
Comment 9 Gustavo Carneiro 2007-07-17 16:46:10 UTC
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.
Comment 10 George Kraft IV 2007-07-17 17:50:39 UTC
Could you please update the patch so that it may be back ported to released systems being maintained?  Thanks.
Comment 11 Gustavo Carneiro 2007-07-17 18:19:56 UTC
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 :)
Comment 12 Gustavo Carneiro 2007-07-17 18:21:39 UTC
And I don't see why you would need it anyway; we make stable releases for a reason :|