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

ruby-changes:35220

From: nobu <ko1@a...>
Date: Thu, 28 Aug 2014 14:55:24 +0900 (JST)
Subject: [ruby-changes:35220] nobu:r47302 (trunk): io.c: preserve encodings

nobu	2014-08-28 14:55:05 +0900 (Thu, 28 Aug 2014)

  New Revision: 47302

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

  Log:
    io.c: preserve encodings
    
    * io.c (rb_io_s_new): preserve encodings in warning messages.

  Modified files:
    trunk/io.c
    trunk/test/ruby/test_io.rb
Index: io.c
===================================================================
--- io.c	(revision 47301)
+++ io.c	(revision 47302)
@@ -7618,9 +7618,9 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/io.c#L7618
 rb_io_s_new(int argc, VALUE *argv, VALUE klass)
 {
     if (rb_block_given_p()) {
-	const char *cname = rb_class2name(klass);
+	VALUE cname = rb_obj_as_string(klass);
 
-	rb_warn("%s::new() does not take block; use %s::open() instead",
+	rb_warn("%"PRIsVALUE"::new() does not take block; use %"PRIsVALUE"::open() instead",
 		cname, cname);
     }
     return rb_class_new_instance(argc, argv, klass);
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 47301)
+++ test/ruby/test_io.rb	(revision 47302)
@@ -2282,7 +2282,12 @@ End https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2282
   end
 
   def test_new_with_block
-    assert_in_out_err([], "r, w = IO.pipe; IO.new(r) {}", [], /^.+$/)
+    assert_in_out_err([], "r, w = IO.pipe; IO.new(r.fileno) {}", [], /^.+$/)
+    n = "IO\u{5165 51fa 529b}"
+    c = eval("class #{n} < IO; self; end")
+    IO.pipe do |r, w|
+      assert_warning(/#{n}/) {c.new(r.fileno) {}}
+    end
   end
 
   def test_readline2

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

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