Avoid mrb_check_string_type() in raising exception; fix
The change may reduce flexibility, but I believe no one wants
that level of flexibility here.
MODIFY
src/error.c
src/error.c
@@ -435,8 +435,8 @@ mrb_bug(mrb_state *mrb, const char *fmt, ...)
exit(EXIT_FAILURE);
}
-static mrb_value
-make_exception(mrb_state *mrb, int argc, const mrb_value *argv, mrb_bool isstr)
+MRB_API mrb_value
+mrb_make_exception(mrb_state *mrb, int argc, const mrb_value *argv)
{
mrb_value mesg;
int n;
@@ -448,13 +448,10 @@ make_exception(mrb_state *mrb, int argc, const mrb_value *argv, mrb_bool isstr)
case 1:
if (mrb_nil_p(argv[0]))
break;
- if (isstr) {
- mesg = mrb_check_string_type(mrb, argv[0]);
- if (!mrb_nil_p(mesg)) {
- mesg = mrb_exc_new_str(mrb, E_RUNTIME_ERROR, mesg);
+ if (mrb_string_p(argv[0])) {
+ mesg = mrb_exc_new_str(mrb, E_RUNTIME_ERROR, argv[0]);
break;
}
- }
n = 0;
goto exception_call;
@@ -488,12 +485,6 @@ exception_call:
return mesg;
}
-MRB_API mrb_value
-mrb_make_exception(mrb_state *mrb, int argc, const mrb_value *argv)
-{
- return make_exception(mrb, argc, argv, TRUE);
-}
-
MRB_API void
mrb_sys_fail(mrb_state *mrb, const char *mesg)
{

MODIFY
src/kernel.c
src/kernel.c
@@ -859,8 +859,8 @@ mrb_f_raise(mrb_state *mrb, mrb_value self)
mrb_raise(mrb, E_RUNTIME_ERROR, "");
break;
case 1:
- a[1] = mrb_check_string_type(mrb, a[0]);
- if (!mrb_nil_p(a[1])) {
+ if (mrb_string_p(a[0])) {
+ a[1] = a[0];
argc = 2;
a[0] = mrb_obj_value(E_RUNTIME_ERROR);
}

Avoid mrb_check_string_type() in raising exception; fix #3506

The change may reduce flexibility, but I believe no one wants
that level of flexibility here.