mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
error.c: bypass Exception.new
* error.c (rb_exc_new, rb_exc_new_str): instantiate exception object directly without Exception.new method call. Redefinition of class method `new` is an outdated style, and internal exceptions should not be affected by it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
64072aa8e1
commit
55515ef463
2 changed files with 5 additions and 5 deletions
|
@ -402,7 +402,7 @@ assert_equal 'nil', %q{
|
||||||
exc.inspect
|
exc.inspect
|
||||||
}, '[ruby-dev:32608]'
|
}, '[ruby-dev:32608]'
|
||||||
|
|
||||||
assert_equal 'exception class/object expected', %q{
|
assert_equal 'divided by 0', %q{
|
||||||
class ZeroDivisionError
|
class ZeroDivisionError
|
||||||
def self.new(message)
|
def self.new(message)
|
||||||
42
|
42
|
||||||
|
|
8
error.c
8
error.c
|
@ -882,7 +882,7 @@ VALUE rb_eSystemCallError;
|
||||||
VALUE rb_mErrno;
|
VALUE rb_mErrno;
|
||||||
static VALUE rb_eNOERROR;
|
static VALUE rb_eNOERROR;
|
||||||
|
|
||||||
static ID id_new, id_cause, id_message, id_backtrace;
|
static ID id_cause, id_message, id_backtrace;
|
||||||
static ID id_name, id_key, id_args, id_Errno, id_errno, id_i_path;
|
static ID id_name, id_key, id_args, id_Errno, id_errno, id_i_path;
|
||||||
static ID id_receiver, id_iseq, id_local_variables;
|
static ID id_receiver, id_iseq, id_local_variables;
|
||||||
static ID id_private_call_p;
|
static ID id_private_call_p;
|
||||||
|
@ -895,7 +895,8 @@ static ID id_private_call_p;
|
||||||
VALUE
|
VALUE
|
||||||
rb_exc_new(VALUE etype, const char *ptr, long len)
|
rb_exc_new(VALUE etype, const char *ptr, long len)
|
||||||
{
|
{
|
||||||
return rb_funcall(etype, id_new, 1, rb_str_new(ptr, len));
|
VALUE mesg = rb_str_new(ptr, len);
|
||||||
|
return rb_class_new_instance(1, &mesg, etype);
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
@ -908,7 +909,7 @@ VALUE
|
||||||
rb_exc_new_str(VALUE etype, VALUE str)
|
rb_exc_new_str(VALUE etype, VALUE str)
|
||||||
{
|
{
|
||||||
StringValue(str);
|
StringValue(str);
|
||||||
return rb_funcall(etype, id_new, 1, str);
|
return rb_class_new_instance(1, &str, etype);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2415,7 +2416,6 @@ Init_Exception(void)
|
||||||
|
|
||||||
rb_define_global_function("warn", rb_warn_m, -1);
|
rb_define_global_function("warn", rb_warn_m, -1);
|
||||||
|
|
||||||
id_new = rb_intern_const("new");
|
|
||||||
id_cause = rb_intern_const("cause");
|
id_cause = rb_intern_const("cause");
|
||||||
id_message = rb_intern_const("message");
|
id_message = rb_intern_const("message");
|
||||||
id_backtrace = rb_intern_const("backtrace");
|
id_backtrace = rb_intern_const("backtrace");
|
||||||
|
|
Loading…
Reference in a new issue