Skip to content

Handling errors inside BOOST_PYTHON_MODULE() #280

Closed
@db4

Description

@db4

I have a module that may fail to initialize due to missing dependencies. So I do

BOOST_PYTHON_MODULE(mymodule)
{
...
    if (missing_dependency) {
        throw std::exception("Missing dependency");
    }
...
}

The exception is correctly caught and PyErr_SetString(PyExc_RuntimeError, x.what()) is called, but python reports

    import mymodule
SystemError: initialization of mymodule raised unreported exception

Why unreported exception? My platform is Windows 10/Python 3.7.4 x64/MSVC 2017 if that matters. python_boost version is 1.69.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions