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

ruby-changes:38248

From: nobu <ko1@a...>
Date: Thu, 16 Apr 2015 20:43:52 +0900 (JST)
Subject: [ruby-changes:38248] nobu:r50329 (trunk): marshal.c: class name encoding

nobu	2015-04-16 20:43:37 +0900 (Thu, 16 Apr 2015)

  New Revision: 50329

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

  Log:
    marshal.c: class name encoding
    
    * marshal.c (w_object): preserve the encoding of the class name in
      an error message.

  Modified files:
    trunk/marshal.c
    trunk/test/ruby/test_marshal.rb
Index: marshal.c
===================================================================
--- marshal.c	(revision 50328)
+++ marshal.c	(revision 50329)
@@ -904,8 +904,8 @@ w_object(VALUE obj, struct dump_arg *arg https://github.com/ruby/ruby/blob/trunk/marshal.c#L904
 	    break;
 
 	  default:
-	    rb_raise(rb_eTypeError, "can't dump %s",
-		     rb_obj_classname(obj));
+	    rb_raise(rb_eTypeError, "can't dump %"PRIsVALUE,
+		     rb_obj_class(obj));
 	    break;
 	}
 	RB_GC_GUARD(obj);
Index: test/ruby/test_marshal.rb
===================================================================
--- test/ruby/test_marshal.rb	(revision 50328)
+++ test/ruby/test_marshal.rb	(revision 50329)
@@ -647,4 +647,11 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L647
       c.cc.call
     end
   end
+
+  def test_undumpable_message
+    c = Module.new {break module_eval("class IO\u{26a1} < IO;self;end")}
+    assert_raise_with_message(TypeError, /IO\u{26a1}/) {
+      Marshal.dump(c.new(0, autoclose: false))
+    }
+  end
 end

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

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