diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-13 05:25:54 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-11-13 05:25:54 +0000 |
commit | 7ab8dcebbf93aef02602f70eb835b030702c0f4f (patch) | |
tree | cfef1c04ddd0a4584e61f77838b91ff9c6481f10 /error.c | |
parent | d432839cbdefc792adce02f9ea759bb2bb3249fd (diff) |
error.c: redefined backtrace
* error.c (rb_get_backtrace): honor redefined Exception#backtrace
method. [ruby-core:78097] [Bug #12925]
* eval.c (setup_exception): rescue exceptions during backtrace
setup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -885,17 +885,20 @@ exc_backtrace(VALUE exc) VALUE rb_get_backtrace(VALUE exc) { - VALUE info, klass = rb_eException; ID mid = id_backtrace; - rb_thread_t *th = GET_THREAD(); - if (NIL_P(exc)) - return Qnil; - EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, exc, mid, mid, klass, Qundef); - info = exc_backtrace(exc); - EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, exc, mid, mid, klass, info); - if (NIL_P(info)) - return Qnil; - return rb_check_backtrace(info); + if (rb_method_basic_definition_p(CLASS_OF(exc), id_backtrace)) { + VALUE info, klass = rb_eException; + rb_thread_t *th = GET_THREAD(); + if (NIL_P(exc)) + return Qnil; + EXEC_EVENT_HOOK(th, RUBY_EVENT_C_CALL, exc, mid, mid, klass, Qundef); + info = exc_backtrace(exc); + EXEC_EVENT_HOOK(th, RUBY_EVENT_C_RETURN, exc, mid, mid, klass, info); + if (NIL_P(info)) + return Qnil; + return rb_check_backtrace(info); + } + return rb_funcall(exc, mid, 0, 0); } /* |