summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-23 11:47:14 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-23 11:47:14 +0000
commiteafe68638040cbb0a2ad07c202e210f1a68b9519 (patch)
tree902dc8bc891f79b4c0402005f09c9c2ae9f67985 /error.c
parente31e4f2a6b93465718f0da2d450c967910814e9c (diff)
merges r20866 and r20891 from trunk into ruby_1_9_1.
* error.c (exc_equal): duck typing equal to make it transitive. [ruby-dev:34880] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/error.c b/error.c
index c28a855ea7..90a7d417e5 100644
--- a/error.c
+++ b/error.c
@@ -554,15 +554,22 @@ exc_set_backtrace(VALUE exc, VALUE bt)
static VALUE
exc_equal(VALUE exc, VALUE obj)
{
+ VALUE mesg, backtrace;
ID id_mesg;
if (exc == obj) return Qtrue;
- if (rb_obj_class(exc) != rb_obj_class(obj))
- return Qfalse;
CONST_ID(id_mesg, "mesg");
- if (!rb_equal(rb_attr_get(exc, id_mesg), rb_attr_get(obj, id_mesg)))
+ if (rb_obj_class(exc) != rb_obj_class(obj)) {
+ mesg = rb_funcall(obj, rb_intern("message"), 0, 0);
+ backtrace = rb_funcall(obj, rb_intern("backtrace"), 0, 0);
+ }
+ else {
+ mesg = rb_attr_get(obj, id_mesg);
+ backtrace = exc_backtrace(obj);
+ }
+ if (!rb_equal(rb_attr_get(exc, id_mesg), mesg))
return Qfalse;
- if (!rb_equal(exc_backtrace(exc), exc_backtrace(obj)))
+ if (!rb_equal(exc_backtrace(exc), backtrace))
return Qfalse;
return Qtrue;
}