properly raise exceptions in python bindings