Re: Exception Handling on Linux

Roman Yakovenko <[email protected]>
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.