Skip to content

Commit

Permalink
Revert "error.c: Let Exception#inspect inspect its message"
Browse files Browse the repository at this point in the history
This reverts commit 9d92720.
  • Loading branch information
mame committed Jun 7, 2022
1 parent 082c2d1 commit b9f0309
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 18 deletions.
12 changes: 2 additions & 10 deletions error.c
Expand Up @@ -34,7 +34,6 @@
#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"
Expand Down Expand Up @@ -1423,15 +1422,8 @@ exc_inspect(VALUE exc)
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;
Expand Down
1 change: 0 additions & 1 deletion internal/string.h
Expand Up @@ -43,7 +43,6 @@ char *rb_str_to_cstr(VALUE str);
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);
Expand Down
2 changes: 1 addition & 1 deletion string.c
Expand Up @@ -6376,7 +6376,7 @@ rb_str_reverse_bang(VALUE str)
*
*/

VALUE
static VALUE
rb_str_include(VALUE str, VALUE arg)
{
long i;
Expand Down
6 changes: 0 additions & 6 deletions test/ruby/test_exception.rb
Expand Up @@ -478,12 +478,6 @@ def test_inspect
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
Expand Down

0 comments on commit b9f0309

Please sign in to comment.