* gc.c (run_final): use rb_thread_critical instead of DEFER_INTS.

[ruby-dev:20272]

* marshal.c: try to make ArgumentError and TypeError consistent.
  [ruby-core:01068]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-05-22 08:30:58 +00:00
parent df62bb4fc9
commit 717302e2c4
3 changed files with 19 additions and 10 deletions

View File

@ -1,3 +1,11 @@
Thu May 22 17:12:10 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* gc.c (run_final): use rb_thread_critical instead of DEFER_INTS.
[ruby-dev:20272]
* marshal.c: try to make ArgumentError and TypeError consistent.
[ruby-core:01068]
Thu May 22 15:46:37 2003 Yukihiro Matsumoto <matz@ruby-lang.org> Thu May 22 15:46:37 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_define_alloc_func): need not to disable * eval.c (rb_define_alloc_func): need not to disable

7
gc.c
View File

@ -1519,10 +1519,11 @@ run_final(obj)
VALUE obj; VALUE obj;
{ {
long i; long i;
int status; int status, critical_save;
VALUE args[2], table; VALUE args[2], table;
DEFER_INTS; critical_save = rb_thread_critical;
rb_thread_critical = Qtrue;
args[1] = rb_ary_new3(1, rb_obj_id(obj)); /* make obj into id */ args[1] = rb_ary_new3(1, rb_obj_id(obj)); /* make obj into id */
for (i=0; i<RARRAY(finalizers)->len; i++) { for (i=0; i<RARRAY(finalizers)->len; i++) {
args[0] = RARRAY(finalizers)->ptr[i]; args[0] = RARRAY(finalizers)->ptr[i];
@ -1534,7 +1535,7 @@ run_final(obj)
rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status); rb_protect((VALUE(*)_((VALUE)))run_single_final, (VALUE)args, &status);
} }
} }
ENABLE_INTS; rb_thread_critical = critical_save;
} }
void void

View File

@ -327,7 +327,7 @@ w_unique(s, arg)
struct dump_arg *arg; struct dump_arg *arg;
{ {
if (s[0] == '#') { if (s[0] == '#') {
rb_raise(rb_eArgError, "can't dump anonymous class %s", s); rb_raise(rb_eTypeError, "can't dump anonymous class %s", s);
} }
w_symbol(rb_intern(s), arg); w_symbol(rb_intern(s), arg);
} }
@ -502,7 +502,7 @@ w_object(obj, arg, limit)
{ {
VALUE path = rb_class_path(obj); VALUE path = rb_class_path(obj);
if (RSTRING(path)->ptr[0] == '#') { if (RSTRING(path)->ptr[0] == '#') {
rb_raise(rb_eArgError, "can't dump anonymous class %s", rb_raise(rb_eTypeError, "can't dump anonymous class %s",
RSTRING(path)->ptr); RSTRING(path)->ptr);
} }
w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg); w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg);
@ -514,7 +514,7 @@ w_object(obj, arg, limit)
{ {
VALUE path = rb_class_path(obj); VALUE path = rb_class_path(obj);
if (RSTRING(path)->ptr[0] == '#') { if (RSTRING(path)->ptr[0] == '#') {
rb_raise(rb_eArgError, "can't dump anonymous module %s", rb_raise(rb_eTypeError, "can't dump anonymous module %s",
RSTRING(path)->ptr); RSTRING(path)->ptr);
} }
w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg); w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg);
@ -588,7 +588,7 @@ w_object(obj, arg, limit)
} }
else if (FL_TEST(obj, FL_USER2)) { else if (FL_TEST(obj, FL_USER2)) {
/* FL_USER2 means HASH_PROC_DEFAULT (see hash.c) */ /* FL_USER2 means HASH_PROC_DEFAULT (see hash.c) */
rb_raise(rb_eArgError, "cannot dump hash with default proc"); rb_raise(rb_eTypeError, "cannot dump hash with default proc");
} }
else { else {
w_byte(TYPE_HASH_DEF, arg); w_byte(TYPE_HASH_DEF, arg);
@ -848,7 +848,7 @@ r_symlink(arg)
if (st_lookup(arg->symbol, num, &id)) { if (st_lookup(arg->symbol, num, &id)) {
return id; return id;
} }
rb_raise(rb_eTypeError, "bad symbol"); rb_raise(rb_eArgError, "bad symbol");
} }
static ID static ID
@ -921,7 +921,7 @@ path2class(path)
VALUE v = rb_path2class(path); VALUE v = rb_path2class(path);
if (TYPE(v) != T_CLASS) { if (TYPE(v) != T_CLASS) {
rb_raise(rb_eTypeError, "%s does not refer class", path); rb_raise(rb_eArgError, "%s does not refer class", path);
} }
return v; return v;
} }
@ -933,7 +933,7 @@ path2module(path)
VALUE v = rb_path2class(path); VALUE v = rb_path2class(path);
if (TYPE(v) != T_MODULE) { if (TYPE(v) != T_MODULE) {
rb_raise(rb_eTypeError, "%s does not refer module", path); rb_raise(rb_eArgError, "%s does not refer module", path);
} }
return v; return v;
} }