Commit 6f7629b4 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Make this closer to CPython

parent ae2e484d
......@@ -596,24 +596,25 @@ extern "C" Box* createUserClass(const std::string* name, Box* _bases, Box* _attr
RELEASE_ASSERT(r, "");
return r;
} catch (ExcInfo e) {
// TODO [CAPI] bad error handling...
RELEASE_ASSERT(e.matches(BaseException), "");
Box* msg = getattr(e.value, "message");
RELEASE_ASSERT(msg, "");
RELEASE_ASSERT(msg->cls == str_cls, "");
PyObject* newmsg;
newmsg = PyString_FromFormat("Error when calling the metaclass bases\n"
" %s",
PyString_AS_STRING(msg));
PyErr_Restore(e.type, newmsg, NULL);
checkAndThrowCAPIException();
Box* msg = e.value;
assert(msg);
// TODO this is an extra Pyston check and I don't think we should have to do it:
if (isSubclass(e.value->cls, BaseException))
msg = getattr(e.value, "message");
if (isSubclass(msg->cls, str_cls)) {
auto newmsg = PyString_FromFormat("Error when calling the metaclass bases\n"
" %s",
PyString_AS_STRING(msg));
if (newmsg)
e.value = newmsg;
}
// Should not reach here
abort();
// Go through these routines since they do some normalization:
PyErr_Restore(e.type, e.value, NULL);
throwCAPIException();
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment