On 3 March 2010 23:08, Ondrej Certik <[email protected]> wrote:
>>
>> Am I being clear enough?
>
> Yes, that is clear to me, thanks.
>

OK. Once you have something working, let's polish it and ask other for
opinions, then push to cython-devel.

>
> That is already implemented, here is my exec function:
>
> cdef api object run_cmd(const_char_p text, object namespace):
>    try:
>        verbose = namespace.get("verbose")
>        if verbose:
>            print "got a text:", text
>        if verbose:
>            print "evaluting in the namespace:"
>            print namespace
>        code = compile(text, "", "exec")
>        eval(code, {}, namespace)
>        if verbose:
>            print "new namespace:"
>            print namespace
>        return namespace
>    except SystemExit, e:
>        try:
>            exit_code = int(e)
>        except:
>            exit_code = -1
>        exit(exit_code)
>    except:
>        etype, value, tb = sys.exc_info()
>        s = "".join(traceback.format_exception(etype, value, tb))
>        s = "Exception raised in the Python code:\n" + s
>        throw_exception(s)
>

Mmm, are you sure you want to handle SystemExit by actually calling
exit(e)?  Is this 'exit' actually 'sys.exit' ? In such case, why just
not use 'raise' to re-raise the exception?

>
> Ok, great! i was worried if there were some issues, but it seems
> everything will work very smoothly and the C++ guys in my group will
> not even notice that they are using Python. :)
>

But they should notice, just to have a chance to fall in love with the beast :-)


-- 
Lisandro Dalcin
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to