ruby-changes:38250
From: nobu <ko1@a...>
Date: Thu, 16 Apr 2015 23:25:35 +0900 (JST)
Subject: [ruby-changes:38250] nobu:r50331 (trunk): marshal.c: class name encoding
nobu 2015-04-16 23:25:19 +0900 (Thu, 16 Apr 2015) New Revision: 50331 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50331 Log: marshal.c: class name encoding * marshal.c (r_object0): preserve the encoding of the class name in an error message, in the case of no _load_data method. Modified files: trunk/marshal.c trunk/test/ruby/test_marshal.rb Index: marshal.c =================================================================== --- marshal.c (revision 50330) +++ marshal.c (revision 50331) @@ -1878,7 +1878,8 @@ r_object0(struct load_arg *arg, int *ivp https://github.com/ruby/ruby/blob/trunk/marshal.c#L1878 case TYPE_DATA: { - VALUE klass = path2class(r_unique(arg)); + VALUE name = r_unique(arg); + VALUE klass = path2class(name); VALUE oldclass = 0; VALUE r; @@ -1889,8 +1890,8 @@ r_object0(struct load_arg *arg, int *ivp https://github.com/ruby/ruby/blob/trunk/marshal.c#L1890 v = r_entry(v, arg); if (!rb_obj_respond_to(v, s_load_data, TRUE)) { rb_raise(rb_eTypeError, - "class %s needs to have instance method `_load_data'", - rb_class2name(klass)); + "class %"PRIsVALUE" needs to have instance method `_load_data'", + name); } r = r_object0(arg, 0, extmod); rb_funcall2(v, s_load_data, 1, &r); Index: test/ruby/test_marshal.rb =================================================================== --- test/ruby/test_marshal.rb (revision 50330) +++ test/ruby/test_marshal.rb (revision 50331) @@ -661,4 +661,16 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L661 Marshal.dump(c.new) } end + + def test_unloadable_data + c = eval("class Unloadable\u{23F0 23F3}<Time;;self;end") + c.class_eval { + alias _dump_data _dump + undef _dump + } + d = Marshal.dump(c.new) + assert_raise_with_message(TypeError, /Unloadable\u{23F0 23F3}/) { + Marshal.load(d) + } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/