aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--object.c5
2 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d4d739d21b..24c8696c55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Tue Mar 29 21:51:31 2011 CHIKANAGA Tomoyuki <nagachika00@gmail.com>
+
+ * string.c (rb_String): Kernel#String should call to_str before to_s.
+
Tue Mar 29 10:28:08 2011 NAKAMURA Usaku <usa@ruby-lang.org>
* test/webrick/test_filehandler.rb
diff --git a/object.c b/object.c
index b25c0af1c2..fad726cd73 100644
--- a/object.c
+++ b/object.c
@@ -2360,7 +2360,10 @@ rb_num2dbl(VALUE val)
VALUE
rb_String(VALUE val)
{
- return rb_convert_type(val, T_STRING, "String", "to_s");
+ VALUE tmp = rb_check_string_type(val);
+ if (NIL_P(tmp))
+ tmp = rb_convert_type(val, T_STRING, "String", "to_s");
+ return tmp;
}