aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-13 05:25:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-13 05:25:54 +0000
commite9786a4eef01cbc6ed44e715b898c694bc380152 (patch)
treecfef1c04ddd0a4584e61f77838b91ff9c6481f10 /error.c
parent7ce6de9328ad72903b1d8222bf838518c587b403 (diff)
downloadruby-e9786a4eef01cbc6ed44e715b898c694bc380152.tar.gz
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.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/error.c b/error.c
index 4503742896..e03a4eea39 100644
--- a/error.c
+++ b/error.c
@@ -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);
}
/*