ruby-changes:38249
From: nobu <ko1@a...>
Date: Thu, 16 Apr 2015 21:46:20 +0900 (JST)
Subject: [ruby-changes:38249] nobu:r50330 (trunk): marshal.c: class name encoding
nobu 2015-04-16 21:46:07 +0900 (Thu, 16 Apr 2015) New Revision: 50330 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50330 Log: marshal.c: class name encoding * marshal.c (w_object): preserve the encoding of the class name in an error message, in the case of no _dump_data method. Modified files: trunk/marshal.c trunk/test/ruby/test_marshal.rb Index: marshal.c =================================================================== --- marshal.c (revision 50329) +++ marshal.c (revision 50330) @@ -893,8 +893,8 @@ w_object(VALUE obj, struct dump_arg *arg https://github.com/ruby/ruby/blob/trunk/marshal.c#L893 if (!rb_obj_respond_to(obj, s_dump_data, TRUE)) { rb_raise(rb_eTypeError, - "no _dump_data is defined for class %s", - rb_obj_classname(obj)); + "no _dump_data is defined for class %"PRIsVALUE, + rb_obj_class(obj)); } v = rb_funcall2(obj, s_dump_data, 0, 0); check_dump_arg(arg, s_dump_data); Index: test/ruby/test_marshal.rb =================================================================== --- test/ruby/test_marshal.rb (revision 50329) +++ test/ruby/test_marshal.rb (revision 50330) @@ -654,4 +654,11 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L654 Marshal.dump(c.new(0, autoclose: false)) } end + + def test_undumpable_data + c = Module.new {break module_eval("class T\u{23F0 23F3}<Time;undef _dump;self;end")} + assert_raise_with_message(TypeError, /T\u{23F0 23F3}/) { + Marshal.dump(c.new) + } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/