Re: [Orbit-python-list] Exception handling inside C modules.
Status: Inactive
Brought to you by:
tack
|
From: Johan D. <zil...@ho...> - 2001-10-04 05:37:28
|
s=F6n 2001-09-30 klockan 08.41 skrev Dominik Smog=F3r:
> Hello everyone.
>=20
>=20
> For last few days I've been trying to wrap some libOAF functions for use
> with
>=20
> Python. Everything went flawlessly until it came to execption handling.
> libOAF
>=20
> calls just return plain CORBA_Evironment and it would be best to just
> behave as
>=20
> if the call was made in orbit-python, that is raise python exception=20
>=20
> created by orbit-python during parsing of oaf.idl (import OAF).=20
>=20
> Therefore I exposed check_corba_ex function into public header (patch
> included).
>=20
> The problem is that calling it from my module causes python to SEGV soon
> after.
>=20
> Is there any special semantics connected with this function? Or maybe
> there is
>=20
> some better way of dealing with CORBA exceptions in C python modules?
>=20
> Regards,
> Domink.
> ----
>=20
Instead of using ORBit-Python's CORBA_Environment, just create a new
one.
But i have already wrapped most parts of oaf in my oafmodule.
It can be found in bonobo-python module in GNOME CVS.
Fortunately you must have bonobo atm.
> --- orbit-python.h Sun Jun 10 17:00:36 2001
> +++ /usr/src/RPM/BUILD/orbit-python-0.3.0-2/src/orbit-python.h Sun Sep 30=
01:42:47 2001
> @@ -23,7 +23,7 @@
> typedef struct {
> PyObject_HEAD
> CORBA_TypeCode tc;=09
> - char *repo_id;
> + char *repo_id;
> } CORBA_TypeCode_PyObject;
> =20
> =20
> @@ -79,7 +79,9 @@
> =20
> PyTypeObject *poam_type;
> POAManager_PyObject *(*poam_new)(PortableServer_POAManager o);
> -
> +=09
> + CORBA_boolean (*checkex)(CORBA_Environment* ev);
> + PyObject *OPExc, *OPSysExt, *OPUsrExt;
> } _ORBitPython_FunctionStruct;
> =09
> #ifdef INSIDE_PYORBIT
> @@ -141,6 +143,12 @@
> #define PyORBit_POAManager_Check(v) ((v)->ob_type =3D=3D _ORBitPython_AP=
I->poam_type)
> #define PyORBit_POAManager_Type *(_ORBitPython_API->poam_type)
> #define PyORBit_POAManager_Get(o) (((POAManager_PyObject*)(o))->obj) =
=20
> +
> +#define PyORBit_CORBA_Environment_Query _ORBitPython_API->checkex
> +
> +#define PyORBit_Exception (_ORBitPython_API->OPExc)
> +#define PyORBit_SystemException (_ORBitPython_API->OPSysExt)
> +#define PyORBit_UserException (_ORBitPython_API->OPUsrExt)
> =20
> #define init_orbit_python() \
> { \
> --- CORBAmodule.c Thu Aug 16 22:19:26 2001
> +++ /usr/src/RPM/BUILD/orbit-python-0.3.0-2/src/CORBAmodule.c Fri Sep 28 =
15:18:32 2001
> @@ -380,7 +380,10 @@
> =20
> &CORBA_TypeCode_PyObject_Type, CORBA_TypeCode_PyObject__new,
> &POA_PyObject_Type, POA_Object_to_PyObject,
> - &POAManager_PyObject_Type, POAManager_Object_to_PyObject
> + &POAManager_PyObject_Type, POAManager_Object_to_PyObject,
> +=09
> + check_corba_ex,
> + NULL,NULL,NULL
> };
> =20
> void initCORBA(void)
> @@ -399,10 +402,7 @@
> =20
> m =3D Py_InitModule("CORBA", CORBA_methods);
> ModuleDict =3D PyModule_GetDict(m);
> -=09
> - PyDict_SetItemString(ModuleDict, "_ORBitPython_API", =20
> - PyCObject_FromVoidPtr(&functions, NULL));
> -=09
> +
> =20
> // Global hashes
> object_glue =3D g_hash_table_new(g_str_hash, g_str_equal);
> @@ -421,6 +421,13 @@
> ORBit_Python_init_consts();
> ORBit_Python_init_marshal();
> ORBit_Python_init_portable_server();
> +
> + functions.OPExc=3DOPExc_Exception;
> + functions.OPSysExt=3DOPExc_SystemException;
> + functions.OPUsrExt=3DOPExc_UserException;
> +=09
> + PyDict_SetItemString(ModuleDict, "_ORBitPython_API", =20
> + PyCObject_FromVoidPtr(&functions, NULL));
> =20
> global_client_module =3D Py_InitModule("_GlobalIDL", empty_methods);
> global_poa_module =3D Py_InitModule("_GlobalIDL__POA", empty_methods);
--=20
-------------------------------------------------
- Johan Dahlin Address: -
- zi...@as... Nygatan 17, nb -
- zil...@ho... 523 30 Ulricehamn -
- PHONE: +46 (0)321-17559 SWEDEN -
- IRC: zilch @ irc.gnome.org -
-------------------------------------------------
|