Discussion:
[omniORB] Problem with struct parameters
Piet van Oostrum
2009-03-03 22:06:37 UTC
Permalink
I have a problem with a struct parameter in omniORBpy. It looks similar
to a problem that appeared on this list 2 weeks ago ("Caught an
unexpected Python exception during up-call") but the situation is quite
different.

I am using omniORB 4.1.3 and omniORBpy-3.3 on MacOS X 10.4 with Python
version 2.6.

I have the following idl:

------------------------------------------------------------------------
module Test {

struct hist {
long lower;
long higher;
};

interface Try {
void meth (out hist h);
};
};
------------------------------------------------------------------------

The server implementation of the method is:

------------------------------------------------------------------------
def meth():
return hist(1, 10)
------------------------------------------------------------------------
because out parameters are implemented as results.

the client code is:

------------------------------------------------------------------------
print server.meth()
------------------------------------------------------------------------

I get an exception:
------------------------------------------------------------------------
omniORB: Caught an unexpected Python exception during up-call.
TypeError: meth() takes no arguments (1 given)
Traceback (most recent call last):
File "client.py", line 30, in <module>
print server.meth()
File "/Users/piet/colleges/GOB/examples/Corba/TestStructOut/strout_idl.py", line 61, in meth
return _omnipy.invoke(self, "meth", _0_Test.Try._d_meth, args)
omniORB.CORBA.UNKNOWN: CORBA.UNKNOWN(omniORB.UNKNOWN_PythonException, CORBA.COMPLETED_MAYBE)
------------------------------------------------------------------------

Where does this argument come from? It is not in my client code. Also if
I change the method in the IDL to return the struct instead of using an
out parameter it gives the same error.

Am I doing something wrong? Is this a bug? Or is omniorbpy incompatible
with python 2.6?
--
Piet van Oostrum <***@cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: ***@vanoostrum.org
Bailey, Kendall
2009-03-03 22:16:16 UTC
Permalink
As meth() is a method of a class, it should have an argument called "self". In C++ and Java, there's an implicit "this" parameter, but in Python the reference to the target of the method call must be explicitly listed first in the argument list. By convention it is called "self". Take a look at this link for the details:

http://www.python.org/doc/2.6/tutorial/classes.html



-------------------------------------------------
Kendall Bailey


-----Original Message-----
From: omniorb-list-***@omniorb-support.com [mailto:omniorb-list-***@omniorb-support.com] On Behalf Of Piet van Oostrum
Sent: Tuesday, March 03, 2009 10:06 AM
To: omniorb-***@omniorb-support.com
Subject: [omniORB] Problem with struct parameters

I have a problem with a struct parameter in omniORBpy. It looks similar
to a problem that appeared on this list 2 weeks ago ("Caught an
unexpected Python exception during up-call") but the situation is quite
different.

I am using omniORB 4.1.3 and omniORBpy-3.3 on MacOS X 10.4 with Python
version 2.6.

I have the following idl:

------------------------------------------------------------------------
module Test {

struct hist {
long lower;
long higher;
};

interface Try {
void meth (out hist h);
};
};
------------------------------------------------------------------------

The server implementation of the method is:

------------------------------------------------------------------------
def meth():
return hist(1, 10)
------------------------------------------------------------------------
because out parameters are implemented as results.

the client code is:

------------------------------------------------------------------------
print server.meth()
------------------------------------------------------------------------

I get an exception:
------------------------------------------------------------------------
omniORB: Caught an unexpected Python exception during up-call.
TypeError: meth() takes no arguments (1 given)
Traceback (most recent call last):
File "client.py", line 30, in <module>
print server.meth()
File "/Users/piet/colleges/GOB/examples/Corba/TestStructOut/strout_idl.py", line 61, in meth
return _omnipy.invoke(self, "meth", _0_Test.Try._d_meth, args)
omniORB.CORBA.UNKNOWN: CORBA.UNKNOWN(omniORB.UNKNOWN_PythonException, CORBA.COMPLETED_MAYBE)
------------------------------------------------------------------------

Where does this argument come from? It is not in my client code. Also if
I change the method in the IDL to return the struct instead of using an
out parameter it gives the same error.

Am I doing something wrong? Is this a bug? Or is omniorbpy incompatible
with python 2.6?
--
Piet van Oostrum <***@cs.uu.nl>
Piet van Oostrum
2009-03-04 03:53:29 UTC
Permalink
BK> http://www.python.org/doc/2.6/tutorial/classes.html
Of course. How stupid. I have it in all other method but for some reason
(blackout?) I forgot to put it in this method, but I did use it in the
method body.
--
Piet van Oostrum <***@cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: ***@vanoostrum.org
Loading...