summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-09 00:04:12 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-09 00:04:12 +0000
commit15fd3268a7274f9bb919bfe42eb663448bdb3969 (patch)
tree7331f81e3394e9ad2a740245d80c78f31604a35b
parentd7bacd080ddbd891e99f32ac6b812a805c96ff01 (diff)
merge revision(s) 21727:
* gc.c (define_final): cannot define finalizer for immediate values. [ruby-core:21500] * gc.c (define_final): freezes or hides internal values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@22832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--gc.c11
-rw-r--r--version.h2
3 files changed, 17 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 16573c693f..f3e12a4459 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Mar 9 09:03:01 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * gc.c (define_final): cannot define finalizer for immediate
+ values. [ruby-core:21500]
+
+ * gc.c (define_final): freezes or hides internal values.
+
Mon Mar 9 08:52:37 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (IS_BEG): EXPR_CLASS should be treated like EXPR_BEG.
diff --git a/gc.c b/gc.c
index 7f9ad06611..51ceb3db10 100644
--- a/gc.c
+++ b/gc.c
@@ -1843,9 +1843,14 @@ define_final(argc, argv, os)
rb_obj_classname(block));
}
need_call_final = 1;
- FL_SET(obj, FL_FINALIZE);
+ if (!FL_ABLE(obj)) {
+ rb_raise(rb_eArgError, "cannot define finalizer for %s",
+ rb_obj_classname(obj));
+ }
+ RBASIC(obj)->flags |= FL_FINALIZE;
block = rb_ary_new3(2, INT2FIX(ruby_safe_level), block);
+ OBJ_FREEZE(block);
if (!finalizer_table) {
finalizer_table = st_init_numtable();
@@ -1854,7 +1859,9 @@ define_final(argc, argv, os)
rb_ary_push(table, block);
}
else {
- st_add_direct(finalizer_table, obj, rb_ary_new3(1, block));
+ table = rb_ary_new3(1, block);
+ RBASIC(table)->klass = 0;
+ st_add_direct(finalizer_table, obj, table);
}
return block;
}
diff --git a/version.h b/version.h
index 776057e7f8..cae459893a 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2009-03-09"
#define RUBY_VERSION_CODE 186
#define RUBY_RELEASE_CODE 20090309
-#define RUBY_PATCHLEVEL 356
+#define RUBY_PATCHLEVEL 357
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8