[omniORB] Creating an Any containing a sequence and an omniORB crash

Duncan Grisby dgrisby@uk.research.att.com
Thu, 21 Sep 2000 14:59:06 +0100


On Thursday 21 September, Carsten Seibert wrote:

> 1) How do I create in Python an Any containing a sequence of something?
> I was not able to figure this out. One need to provide a type code for
> the __init__ of class Any and I could not find the equivalent
> TC_sequence type code.

If the sequence type you require is defined in IDL somewhere, for
example:

  module M {
    typedef sequence long longs;
  };

then you can get hold of the TypeCode you need with a combination of
the CORBA.TypeCode and CORBA.id functions:

  tc = CORBA.TypeCode(CORBA.id(M.longs))
  a  = CORBA.Any(tc, [1,2,3,4,5])

(In fact, in omniORBpy you can also get the TypeCode using the name
M._tc_longs, but that is not part of the Python mapping standard.)


If you do not have any IDL for the sequence type, you have to use the
ORB's TypeCode creation functions:

  tc = orb.create_sequence_tc(0, CORBA.TC_long)
  a  = CORBA.Any(tc, [1,2,3,4,5])


Note that the two TypeCodes you get in these cases are subtly
different: in the first case, you get a TypeCode for an alias to a
sequence of longs; in the second, you get a TypeCode for just a
sequence of longs. i.e. the TypeCodes are equivalent but not equal:

>>> tc1 = CORBA.TypeCode(CORBA.id(M.longs))
>>> tc2 = orb.create_sequence_tc(0, CORBA.TC_long)
>>> tc1.kind()
CORBA.tk_alias
>>> tc2.kind()
CORBA.tk_sequence
>>> tc1.equal(tc2)
0
>>> tc1.equivalent(tc2)
1


> 2) Is there a service in omniORBpy that can tells me the corresponding
> CORBA type code for a given Python base type? This would help to
> facilitate the creation of Anys without always having to specify
> explicitly the type code. I suppose that this knowledge is required for
> marshaling anyway but is this still Python?

Do you mean that given a Python string object, for example, it would
give you the TypeCode for CORBA string?  If so, then there is no way
to do that -- many of the CORBA types map to the same Python types, so
it would do the wrong thing too often. Python strings are used for
CORBA sequences of octets and chars, as well as strings, for instance.

[...]
> In one particular case where this any (defaultValue) contains a sequence
> with one string, omniORB crashes during unmarshal of the reply when my
> Python client invokes this operation on a server (Smalltalk). After

This is a very silly bug with the sequence marshalling code. It's
fixed in CVS and the bugfixes patch. The bug prevented sequences and
arrays of anys from working.

> 4) Does anybody has a Python (1.5.2) binary for HP-UX 11 compiled with
> the HP compiler? We've compiled Python with gcc which seems to cause
> problems when you want to use the pre-compiled omniORBpy distribution. I
> did not manage to load the omniORB shared libraries due to some library
> problems/incompatabilities between gcc and the HP compiler.

You'll probably find that the HPUX python executable from the minimal
distributions in ftp://ftp.uk.research.att.com/pub/omniORB/python/
does what you want. However, to get the above bug fix before we do
another full release of omniORBpy, you'll have to compile omniORBpy
yourself anyway.

Cheers,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --