[C++-sig] Converting from SWIG to Boost.Python

BHELLA,OPINDERJIT (HP-Vancouver,ex1) opinderjit.bhella at hp.com
Thu Jan 30 20:52:19 CET 2003


Hi, 

I have been using SWIG 1.5p for about a year with good success. However, I
was interested in the newer functionality
that Boost.Python provides. I have read through the tutorial and was unable
to figure out how to reproduce the
following SWIG logic that uses the Py_BEGIN_ALLOW_THREADS and
Py_END_ALLOW_THREADS macros.

Thanks.

SWIG example:
%except(python)
{
    Py_BEGIN_ALLOW_THREADS
    try
    {
        $function
    }
    catch(BlackstoneErrorObject &e)
    {
        PyEval_RestoreThread(_save);
        switch(e.getCode())
        {
            case SUCCESS: ...                 break;
            case GENERAL_ERROR:        break;
            default: ...break;
        }
        return NULL;
    }
    catch (...)
    {
        PyEval_RestoreThread(_save);
        PyErr_SetString(BlackstoneError,"...");
        return NULL;
    }
    Py_END_ALLOW_THREADS
}




More information about the Cplusplus-sig mailing list