On Jun 27, 2008, at 6:43 AM, Johannes Wienke wrote:

Hi again,

I've got the following problem:
There is client code of my application that is already written and cotains so lines of code like these ones:

void foo(int c) {

        if (c < 5) {
                gui_exit(1)
        }

        // do some other things that fail if c is < 5

}

I am the one who has to implement gui_exit, which was originally a wrapper for the normal C exit function doing some clean up.

My first attempt to implement gui_exit in cython was using sys.exit. The problem with this approach is that sys.exit depends on exceptions, which are only checked after the client routine is completely processed. So foo does not exit at gui_exit and possibly generates a segmentation fault in the other things it does.

Is there a solution for this problem, that uses the python exit mechanism? I need that to clean up resources.

Thanks for the help
Johannes

Try


void foo(int c) {

        if (c < 5) {
                gui_exit(1)
        }

        else {

        // do some other things that fail if c is < 5

        }

}



Also, look at the exception passing mechanisms at http:// www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/Manual/ basics.html#mozTocId482761

- Robert

Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to