1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* error.c (exc_equal): try implicit conversion for delegator.

[ruby-core:41979] [Bug #5865]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-01-13 07:44:50 +00:00
parent 1c58146ee5
commit a5bfe7ca83
3 changed files with 16 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Fri Jan 13 16:44:45 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* error.c (exc_equal): try implicit conversion for delegator.
[ruby-core:41979] [Bug #5865]
Fri Jan 13 03:46:53 2012 Akinori MUSHA <knu@iDaemons.org>
* lib/shellwords.rb (Shellwords#shellescape): shellescape() now

View file

@ -732,10 +732,14 @@ exc_equal(VALUE exc, VALUE obj)
CONST_ID(id_mesg, "mesg");
if (rb_obj_class(exc) != rb_obj_class(obj)) {
ID id_message, id_backtrace;
ID id_exception, id_message, id_backtrace;
CONST_ID(id_exception, "exception");
CONST_ID(id_message, "message");
CONST_ID(id_backtrace, "backtrace");
obj = rb_check_funcall(obj, id_exception, 0, 0);
if (obj == Qundef) return Qfalse;
if (rb_obj_class(exc) != rb_obj_class(obj)) return Qfalse;
mesg = rb_check_funcall(obj, id_message, 0, 0);
if (mesg == Qundef) return Qfalse;
backtrace = rb_check_funcall(obj, id_backtrace, 0, 0);

View file

@ -380,4 +380,10 @@ end.join
load(t.path)
end
end
def test_equal
bug5865 = '[ruby-core:41979]'
assert_equal(RuntimeError.new("a"), RuntimeError.new("a"), bug5865)
assert_not_equal(RuntimeError.new("a"), StandardError.new("a"), bug5865)
end
end