diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-18 23:42:00 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-18 23:42:00 +0000 |
| commit | ef75a8095669cd05473ccaf99cf27731204621b9 (patch) | |
| tree | f6cbfd1de005cf7345c8222106d11607732fd13b /error.c | |
| parent | 95c85c3ff65c2dfc4b0533f3e285c5ab977a4273 (diff) | |
| download | ruby-ef75a8095669cd05473ccaf99cf27731204621b9.tar.gz ruby-ef75a8095669cd05473ccaf99cf27731204621b9.tar.xz ruby-ef75a8095669cd05473ccaf99cf27731204621b9.zip | |
* error.c (exc_equal): duck typing equal to make it transitive.
[ruby-dev:34880]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
| -rw-r--r-- | error.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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; } |
