From 6cb24cee643bfde273cd879e37d3f01c8b309388 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 28 Oct 2013 04:17:20 +0000 Subject: [PATCH] error.c: remove NameError#to_s * error.c (name_err_to_s): remove no longer needed overriding, since r30455 which made exc_to_s almost same. Fixes [GH-413]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ error.c | 23 +---------------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78a8851329..16fb98f64e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Oct 28 13:17:17 2013 Or Cohen + + * error.c (name_err_to_s): remove no longer needed overriding, since + r30455 which made exc_to_s almost same. Fixes [GH-413]. + Mon Oct 28 12:42:11 2013 Tanaka Akira * common.mk, ext/objspace/depend, ext/coverage/depend, diff --git a/error.c b/error.c index c8d51c101d..ba9c720821 100644 --- a/error.c +++ b/error.c @@ -641,11 +641,9 @@ static VALUE exc_to_s(VALUE exc) { VALUE mesg = rb_attr_get(exc, rb_intern("mesg")); - VALUE r = Qnil; if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc)); - r = rb_String(mesg); - return r; + return rb_String(mesg); } /* @@ -991,24 +989,6 @@ name_err_name(VALUE self) return rb_attr_get(self, rb_intern("name")); } -/* - * call-seq: - * name_error.to_s -> string - * - * Produce a nicely-formatted string representing the +NameError+. - */ - -static VALUE -name_err_to_s(VALUE exc) -{ - VALUE mesg = rb_attr_get(exc, rb_intern("mesg")); - VALUE str = mesg; - - if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc)); - StringValue(str); - return str; -} - /* * call-seq: * NoMethodError.new(msg, name [, args]) -> no_method_error @@ -1790,7 +1770,6 @@ Init_Exception(void) rb_eNameError = rb_define_class("NameError", rb_eStandardError); rb_define_method(rb_eNameError, "initialize", name_err_initialize, -1); rb_define_method(rb_eNameError, "name", name_err_name, 0); - rb_define_method(rb_eNameError, "to_s", name_err_to_s, 0); rb_cNameErrorMesg = rb_define_class_under(rb_eNameError, "message", rb_cData); rb_define_singleton_method(rb_cNameErrorMesg, "!", rb_name_err_mesg_new, NAME_ERR_MESG_COUNT); rb_define_method(rb_cNameErrorMesg, "==", name_err_mesg_equal, 1);