Project

General

Profile

Actions

Bug #2208

closed

Exception#inspect の message 部が inspect されていない

Added by naruse (Yui NARUSE) over 14 years ago. Updated almost 13 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-10-13 trunk 25324) [x86_64-freebsd7.2]
Backport:

Description

=begin
通常 Object#inspect の結果にでてくる文字列は inspect されています。
しかし、Exception#inspect はそのままになっています。
http://shinh.skr.jp/m/?date=20091014#c02

class Foo;def initialize;@a="\t";end;end
Foo.new.inspect #=> #<Foo:0x000008012dffd8 @A (A A)="\t">

Exception.new("\t") #=> #<Exception: " ">

単なるかけ忘れな気がするのですがどうでしょう。

diff --git a/error.c b/error.c
index a7342de..3a5580a 100644
--- a/error.c
+++ b/error.c
@@ -458,7 +458,7 @@ exc_exception(int argc, VALUE *argv, VALUE self)
static VALUE
exc_to_s(VALUE exc)
{

  • VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
  • VALUE mesg = rb_inspect(rb_attr_get(exc, rb_intern("mesg")));

    if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
    if (OBJ_TAINTED(exc)) OBJ_TAINT(mesg);
    =end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0