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

ruby-changes:36467

From: nobu <ko1@a...>
Date: Mon, 24 Nov 2014 02:04:00 +0900 (JST)
Subject: [ruby-changes:36467] nobu:r48549 (trunk): string.c: preserve encoding of global variable

nobu	2014-11-24 02:03:48 +0900 (Mon, 24 Nov 2014)

  New Revision: 48549

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48549

  Log:
    string.c: preserve encoding of global variable
    
    * string.c (rb_str_setter): preserve encoding of global variable
      name in error message.

  Modified files:
    trunk/ChangeLog
    trunk/string.c
    trunk/test/ruby/test_string.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48548)
+++ ChangeLog	(revision 48549)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Nov 24 02:03:40 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (rb_str_setter): preserve encoding of global variable
+	  name in error message.
+
 Mon Nov 24 02:03:30 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* iseq.c (rb_insn_operand_intern): preserve encoding of method
Index: string.c
===================================================================
--- string.c	(revision 48548)
+++ string.c	(revision 48549)
@@ -7998,7 +7998,7 @@ void https://github.com/ruby/ruby/blob/trunk/string.c#L7998
 rb_str_setter(VALUE val, ID id, VALUE *var)
 {
     if (!NIL_P(val) && !RB_TYPE_P(val, T_STRING)) {
-	rb_raise(rb_eTypeError, "value of %s must be String", rb_id2name(id));
+	rb_raise(rb_eTypeError, "value of %"PRIsVALUE" must be String", rb_id2str(id));
     }
     *var = val;
 }
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb	(revision 48548)
+++ test/ruby/test_string.rb	(revision 48549)
@@ -2056,6 +2056,11 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L2056
 
   def test_setter
     assert_raise(TypeError) { $/ = 1 }
+    name = "\u{5206 884c}"
+    assert_separately([], <<-"end;") #    do
+      alias $#{name} $/
+      assert_raise_with_message(TypeError, /\\$#{name}/) { $#{name} = 1 }
+    end;
   end
 
   def test_to_id

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

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