summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-09 00:05:03 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-09 00:05:03 +0000
commit0b85e2a0a7d95a7572fff1650d0217d66d7defda (patch)
tree111f6c70763de59fd2d88381ad817d9a9ddf1642
parent2d281863caef13ca12530822f682d174f833cee6 (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_7@22834 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 1ae9ec64be..f554c613fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Mar 9 09:04:39 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:54:47 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 111220eb76..489533251d 100644
--- a/gc.c
+++ b/gc.c
@@ -1887,9 +1887,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();
@@ -1898,7 +1903,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 765c0f1f34..6c4059b527 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2009-03-09"
#define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20090309
-#define RUBY_PATCHLEVEL 145
+#define RUBY_PATCHLEVEL 146
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8