[前][次][番号順一覧][スレッド一覧]

ruby-changes:72082

From: Yusuke <ko1@a...>
Date: Tue, 7 Jun 2022 11:52:56 +0900 (JST)
Subject: [ruby-changes:72082] b9f030954a (master): Revert "error.c: Let Exception#inspect inspect its message"

https://git.ruby-lang.org/ruby.git/commit/?id=b9f030954a

From b9f030954a8a1572032f3548b39c5b8ac35792ce Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Tue, 7 Jun 2022 11:50:58 +0900
Subject: Revert "error.c: Let Exception#inspect inspect its message"

This reverts commit 9d927204e7b86eb00bfd07a060a6383139edf741.
---
 error.c                     | 12 ++----------
 internal/string.h           |  1 -
 string.c                    |  2 +-
 test/ruby/test_exception.rb |  6 ------
 4 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/error.c b/error.c
index 08b0c8da72..3f5c05d681 100644
--- a/error.c
+++ b/error.c
@@ -34,7 +34,6 @@ https://github.com/ruby/ruby/blob/trunk/error.c#L34
 #include "internal/io.h"
 #include "internal/load.h"
 #include "internal/object.h"
-#include "internal/string.h"
 #include "internal/symbol.h"
 #include "internal/thread.h"
 #include "internal/variable.h"
@@ -1423,15 +1422,8 @@ exc_inspect(VALUE exc) https://github.com/ruby/ruby/blob/trunk/error.c#L1422
     str = rb_str_buf_new2("#<");
     klass = rb_class_name(klass);
     rb_str_buf_append(str, klass);
-
-    if (RTEST(rb_str_include(exc, rb_str_new2("\n")))) {
-        rb_str_catf(str, ":%+"PRIsVALUE, exc);
-    }
-    else {
-        rb_str_buf_cat(str, ": ", 2);
-        rb_str_buf_append(str, exc);
-    }
-
+    rb_str_buf_cat(str, ": ", 2);
+    rb_str_buf_append(str, exc);
     rb_str_buf_cat(str, ">", 1);
 
     return str;
diff --git a/internal/string.h b/internal/string.h
index 57a4af49c7..18b01862f7 100644
--- a/internal/string.h
+++ b/internal/string.h
@@ -43,7 +43,6 @@ char *rb_str_to_cstr(VALUE str); https://github.com/ruby/ruby/blob/trunk/internal/string.h#L43
 const char *ruby_escaped_char(int c);
 void rb_str_make_independent(VALUE str);
 int rb_enc_str_coderange_scan(VALUE str, rb_encoding *enc);
-VALUE rb_str_include(VALUE str, VALUE arg);
 
 static inline bool STR_EMBED_P(VALUE str);
 static inline bool STR_SHARED_P(VALUE str);
diff --git a/string.c b/string.c
index 9c37d774b3..83d90ff3a9 100644
--- a/string.c
+++ b/string.c
@@ -6376,7 +6376,7 @@ rb_str_reverse_bang(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L6376
  *
  */
 
-VALUE
+static VALUE
 rb_str_include(VALUE str, VALUE arg)
 {
     long i;
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index acc3228e2f..0b05ff7c51 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -478,12 +478,6 @@ end.join https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L478
       def to_s; ""; end
     end
     assert_equal(e.inspect, e.new.inspect)
-
-    # https://bugs.ruby-lang.org/issues/18170#note-13
-    assert_equal('#<Exception:"foo\nbar">', Exception.new("foo\nbar").inspect)
-    assert_equal('#<Exception: foo bar>', Exception.new("foo bar").inspect)
-    assert_equal('#<Exception: foo\bar>', Exception.new("foo\\bar").inspect)
-    assert_equal('#<Exception: "foo\nbar">', Exception.new('"foo\nbar"').inspect)
   end
 
   def test_to_s
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]