marshal.c: class name encoding
* marshal.c (r_object0): preserve the encoding of the class name in an error message, in the case of USERDEF without _load singleton method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
53e4fb8c80
commit
0ea135d177
@ -1815,12 +1815,13 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
|
|||||||
|
|
||||||
case TYPE_USERDEF:
|
case TYPE_USERDEF:
|
||||||
{
|
{
|
||||||
VALUE klass = path2class(r_unique(arg));
|
VALUE name = r_unique(arg);
|
||||||
|
VALUE klass = path2class(name);
|
||||||
VALUE data;
|
VALUE data;
|
||||||
|
|
||||||
if (!rb_obj_respond_to(klass, s_load, TRUE)) {
|
if (!rb_obj_respond_to(klass, s_load, TRUE)) {
|
||||||
rb_raise(rb_eTypeError, "class %s needs to have method `_load'",
|
rb_raise(rb_eTypeError, "class %"PRIsVALUE" needs to have method `_load'",
|
||||||
rb_class2name(klass));
|
name);
|
||||||
}
|
}
|
||||||
data = r_string(arg);
|
data = r_string(arg);
|
||||||
if (ivp) {
|
if (ivp) {
|
||||||
|
@ -673,4 +673,15 @@ class TestMarshal < Test::Unit::TestCase
|
|||||||
Marshal.load(d)
|
Marshal.load(d)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_unloadable_userdef
|
||||||
|
c = eval("class Userdef\u{23F0 23F3}<Time;self;end")
|
||||||
|
class << c
|
||||||
|
undef _load
|
||||||
|
end
|
||||||
|
d = Marshal.dump(c.new)
|
||||||
|
assert_raise_with_message(TypeError, /Userdef\u{23F0 23F3}/) {
|
||||||
|
Marshal.load(d)
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user