Re: Exception Handling on Linux
"Bilokon, Paul " <[email protected]>
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
Hi Roman, My apologies, I meant a C++ function. Many thanks for your explanation. If I throw an C++ exception, which isn't handled eventually, do I get a signal on Linux? If so, is there any way to get at it in Python? Changing the function is probably not an option, but I would like to at least prevent it from core-dumping and return to my Python code. Best wishes, Paul -----Original Message----- From: Roman Yakovenko [mailto:[email protected]] Sent: 16 December 2009 13:02 To: Bilokon, Paul [ICG-MKTS] Cc: [email protected] Subject: Re: [ctypes-users] Exception Handling on Linux On Wed, Dec 16, 2009 at 2:00 PM, Bilokon, Paul <[email protected]> wrote: > Hi all, > > If a Linux C function has thrown an exception, is there a way to catch > it on the Python side? I could be wrong, but "C" language doesn't have exception. Did you compiled "C" code with "C++" compiler? > I have managed to handle exceptions on Windows catching the WindowsError. > > However, whenever my Linux code throws an exception, I never get a > chance to recover. Is this documented anywhere? The internal ( OS ) mechanism is very different between Windows and Linux. Linux will send you signal. It is possible to convert that signal to exception, but the resulting code is very very fragile and it is not portable. If you can't change the function ( to report the error via in-out argument ), then you can create a function wrapper and convert exception to some else. HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev