objexcept: Add mp_obj_new_exception_arg1() convenience function.

This commit is contained in:
Paul Sokolovsky
2014-04-22 00:01:13 +03:00
parent b418b6fb0d
commit dec31bb872
2 changed files with 6 additions and 0 deletions

View File

@@ -191,6 +191,11 @@ mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type) {
return mp_obj_new_exception_args(exc_type, 0, NULL);
}
// "Optimized" version for common(?) case of having 1 exception arg
mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) {
return mp_obj_new_exception_args(exc_type, 1, &arg);
}
mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, uint n_args, const mp_obj_t *args) {
assert(exc_type->make_new == mp_obj_exception_make_new);
return exc_type->make_new((mp_obj_t)exc_type, n_args, 0, args);