Skip to content

Add exceptions to modules #732

@fubuloubu

Description

@fubuloubu

After creating a new exception using:

create_exception!(my_module, MyException, ExceptionClass);

It is natural that I would want to make it available as an import within my python module:

from my_module import MyException

However, in order to do this, I had to do some deep Kung Foo action:

#[pymodule]
fn my_module(py: Python, m: PyModule) {
    m.add("MyException", py.get_type::<MyException>())?;
}

It would be nice to have an easier API for this:

#[pymodule]
fn my_module(_py: Python, m: PyModule) {
    m.add_exception::<MyException>()?;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions