1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* marshal.c (class2path): check anonymous class/module before

checking referable, and allow singleton classes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2004-01-17 15:23:59 +00:00
parent 292b3ecbb4
commit 13fa93f777
2 changed files with 12 additions and 10 deletions

View file

@ -1,3 +1,8 @@
Sun Jan 18 00:23:55 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (class2path): check anonymous class/module before
checking referable, and allow singleton classes.
Sat Jan 17 23:58:51 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* error.c (NameError::Message): new class for lazy evaluation of

View file

@ -105,8 +105,13 @@ class2path(klass)
VALUE path = rb_class_path(klass);
char *n = RSTRING(path)->ptr;
if (rb_path2class(n) != klass) {
rb_raise(rb_eArgError, "%s cannot be referred", n);
if (n[0] == '#') {
rb_raise(rb_eTypeError, "can't dump anonymous %s %s",
(TYPE(klass) == T_CLASS ? "class" : "module"),
n);
}
if (rb_path2class(n) != rb_class_real(klass)) {
rb_raise(rb_eTypeError, "%s cannot be referred", n);
}
return path;
}
@ -531,10 +536,6 @@ w_object(obj, arg, limit)
w_byte(TYPE_CLASS, arg);
{
VALUE path = class2path(obj);
if (RSTRING(path)->ptr[0] == '#') {
rb_raise(rb_eTypeError, "can't dump anonymous class %s",
RSTRING(path)->ptr);
}
w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg);
}
break;
@ -543,10 +544,6 @@ w_object(obj, arg, limit)
w_byte(TYPE_MODULE, arg);
{
VALUE path = class2path(obj);
if (RSTRING(path)->ptr[0] == '#') {
rb_raise(rb_eTypeError, "can't dump anonymous module %s",
RSTRING(path)->ptr);
}
w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg);
}
break;