[omniORB] omniidl -bpython bug

Luke Deller ldeller at xplantechnology.com
Tue Sep 27 13:39:00 BST 2005


Hi,

In the case where two IDL files contribute to the same CORBA module, and
a third IDL file #include's one of those IDL files, then "omniidl
-bpython" generates wrong stubs.  Here's an example:

bash$ cat > foo.idl <<EOF
#include "bar.idl"
module foo {
    const long fooval = 42;
};
EOF
bash$ cat > bar.idl <<EOF
module bar {
    const long barval = 42;
};
EOF
bash$ cat > bar2.idl <<EOF
module bar {
    const long barval2 = 43;
};
EOF
bash$ omniidl -bpython foo.idl bar.idl bar2.idl
bash$ python
Python 2.4.1 (#1, May 19 2005, 15:25:51)
[GCC 3.4.3-20050110 (Gentoo Linux 3.4.3.20050110, ssp-3.4.3.20050110-0,
pie-8.7 on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>> import bar
>>> bar.barval
42
>>> bar.barval2
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'module' object has no attribute 'barval2'


In the above example, if the "import foo" and "import bar" lines are
swapped, then it works fine (ie bar.barval2 exists with the value 43).

The problem is caused as follows:
foo/__init__.py imports foo_idl.py
foo_idl.py imports bar_idl.py
bar_idl.py calls omniORB.openModule("bar", r"bar.idl")
omniORB.openModule calls omniORB.newModule("bar")
omniORB.newModule calls imp.new_module
this new empty module is inserted into sys.modules["bar"]

Thus bar/__init__.py is never imported, and so bar2_idl.py is never
imported, so the definitions from bar2.idl are never inserted into the
bar module.

Perhaps omniORB.openModule should use __import__ rather than
imp.new_module ?

Regards,
Luke.

**********************************************************************************************

Important Note
This email (including any attachments) contains information which is
confidential and may be subject to legal privilege.  If you are not
the intended recipient you must not use, distribute or copy this
email.  If you have received this email in error please notify the
sender immediately and delete this email. Any views expressed in this
email are not necessarily the views of XPlan Technology.

It is the duty of the recipient to virus scan and otherwise test the
information provided before loading onto any computer system.
Xplan Technology does not warrant that the
information is free of a virus or any other defect or error.
**********************************************************************************************




More information about the omniORB-list mailing list