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

ruby-changes:36465

From: nobu <ko1@a...>
Date: Mon, 24 Nov 2014 02:03:34 +0900 (JST)
Subject: [ruby-changes:36465] nobu:r48546 (trunk): io.c: preserve encodings

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

  New Revision: 48546

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

  Log:
    io.c: preserve encodings
    
    * io.c (must_respond_to): preserve encodings of variable name and
      class name in warning message.

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/test/ruby/test_io.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48545)
+++ ChangeLog	(revision 48546)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Nov 24 02:02:59 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* io.c (must_respond_to): preserve encodings of variable name and
+	  class name in warning message.
+
 Sun Nov 23 10:46:23 2014  Eric Wong  <e@8...>
 
 	* internal.h (struct rb_execarg): 160 => 144 bytes on x86-64
Index: io.c
===================================================================
--- io.c	(revision 48545)
+++ io.c	(revision 48546)
@@ -7275,9 +7275,9 @@ static void https://github.com/ruby/ruby/blob/trunk/io.c#L7275
 must_respond_to(ID mid, VALUE val, ID id)
 {
     if (!rb_respond_to(val, mid)) {
-	rb_raise(rb_eTypeError, "%s must have %s method, %s given",
-		 rb_id2name(id), rb_id2name(mid),
-		 rb_obj_classname(val));
+	rb_raise(rb_eTypeError, "%"PRIsVALUE" must have %"PRIsVALUE" method, %"PRIsVALUE" given",
+		 rb_id2str(id), rb_id2str(mid),
+		 rb_obj_class(val));
     }
 }
 
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 48545)
+++ test/ruby/test_io.rb	(revision 48546)
@@ -2268,6 +2268,14 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2268
     assert_raise(TypeError) { $> = Object.new }
 
     assert_in_out_err([], "$> = $stderr\nputs 'foo'", [], %w(foo))
+
+    assert_separately(%w[-Eutf-8], <<-"end;") #    do
+      alias $\u{6a19 6e96 51fa 529b} $stdout
+      x = eval("class X\u{307b 3052}; self; end".encode("euc-jp"))
+      assert_raise_with_message(TypeError, /\\$\u{6a19 6e96 51fa 529b} must.*, X\u{307b 3052} given/) do
+        $\u{6a19 6e96 51fa 529b} = x.new
+      end
+    end;
   end
 
   def test_initialize

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

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