summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-24 13:39:57 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-24 13:39:57 +0000
commit582da7dac70c7fd9c9927cd57587e0cebfebfb3d (patch)
treee0bdac054327f84e64068a4c9d03f76061c3722f /error.c
parent8707a6ff4b380790549aee1d7c6f023461580f6c (diff)
* error.c (exc_equal): == operator should be transitional.
[ruby-dev:34808] * error.c (syserr_eqq): === should be able to handle delegated objects as well. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/error.c b/error.c
index 96a31ced87..f339fb3858 100644
--- a/error.c
+++ b/error.c
@@ -556,7 +556,7 @@ exc_equal(VALUE exc, VALUE obj)
if (exc == obj) return Qtrue;
if (rb_obj_class(exc) != rb_obj_class(obj))
- return Qfalse;
+ return rb_equal(obj, exc);
if (!rb_equal(rb_attr_get(exc, id_mesg), rb_attr_get(obj, id_mesg)))
return Qfalse;
if (!rb_equal(exc_backtrace(exc), exc_backtrace(obj)))
@@ -963,18 +963,16 @@ static VALUE
syserr_eqq(VALUE self, VALUE exc)
{
VALUE num, e;
+ ID en = rb_intern("errno");
- if (!rb_obj_is_kind_of(exc, rb_eSystemCallError)) return Qfalse;
- if (self == rb_eSystemCallError) return Qtrue;
+ if (!rb_obj_is_kind_of(exc, rb_eSystemCallError)) {
+ if (!rb_respond_to(exc, en)) return Qfalse;
+ }
+ else if (self == rb_eSystemCallError) return Qtrue;
num = rb_attr_get(exc, rb_intern("errno"));
if (NIL_P(num)) {
- VALUE klass = CLASS_OF(exc);
-
- while (TYPE(klass) == T_ICLASS || FL_TEST(klass, FL_SINGLETON)) {
- klass = (VALUE)RCLASS_SUPER(klass);
- }
- num = rb_const_get(klass, rb_intern("Errno"));
+ num = rb_funcall(exc, en, 0, 0);
}
e = rb_const_get(self, rb_intern("Errno"));
if (FIXNUM_P(num) ? num == e : rb_equal(num, e))