mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2c1c5570e8
commit
bdf16df33a
2 changed files with 9 additions and 2 deletions
|
@ -893,8 +893,8 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
|
|||
|
||||
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);
|
||||
|
|
|
@ -654,4 +654,11 @@ class TestMarshal < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue