[前][次][番号順一覧][スレッド一覧]

ruby-changes:13151

From: nobu <ko1@a...>
Date: Sun, 13 Sep 2009 22:18:49 +0900 (JST)
Subject: [ruby-changes:13151] Ruby:r24903 (trunk): * variable.c (rb_mod_remove_const): do not change VM state when an

nobu	2009-09-13 22:18:35 +0900 (Sun, 13 Sep 2009)

  New Revision: 24903

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24903

  Log:
    * variable.c (rb_mod_remove_const): do not change VM state when an
      exception will occur.

  Modified files:
    trunk/ChangeLog
    trunk/variable.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 24902)
+++ ChangeLog	(revision 24903)
@@ -1,3 +1,8 @@
+Sun Sep 13 22:18:33 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* variable.c (rb_mod_remove_const): do not change VM state when an
+	  exception will occur.
+
 Sun Sep 13 21:25:01 2009  Masaki Suketa  <masaki.suketa@n...>
 
 	* ext/win32ole/win32ole.c (oletypelib_get_libattr): some refactoring
Index: variable.c
===================================================================
--- variable.c	(revision 24902)
+++ variable.c	(revision 24903)
@@ -1596,8 +1596,6 @@
     VALUE val;
     st_data_t v, n = id;
 
-    rb_vm_change_state();
-
     if (!rb_is_const_id(id)) {
 	rb_name_error(id, "`%s' is not allowed as a constant name", rb_id2name(id));
     }
@@ -1605,21 +1603,23 @@
 	rb_raise(rb_eSecurityError, "Insecure: can't remove constant");
     if (OBJ_FROZEN(mod)) rb_error_frozen("class/module");
 
-    if (RCLASS_IV_TBL(mod) && st_delete(RCLASS_IV_TBL(mod), &n, &v)) {
-	val = (VALUE)v;
-	if (val == Qundef) {
-	    autoload_delete(mod, id);
-	    val = Qnil;
+    if (!RCLASS_IV_TBL(mod) || !st_delete(RCLASS_IV_TBL(mod), &n, &v)) {
+	if (rb_const_defined_at(mod, id)) {
+	    rb_name_error(id, "cannot remove %s::%s",
+			  rb_class2name(mod), rb_id2name(id));
 	}
-	return val;
+	rb_name_error(id, "constant %s::%s not defined",
+		      rb_class2name(mod), rb_id2name(id));
     }
-    if (rb_const_defined_at(mod, id)) {
-	rb_name_error(id, "cannot remove %s::%s",
-		 rb_class2name(mod), rb_id2name(id));
+
+    rb_vm_change_state();
+
+    val = (VALUE)v;
+    if (val == Qundef) {
+	autoload_delete(mod, id);
+	val = Qnil;
     }
-    rb_name_error(id, "constant %s::%s not defined",
-		  rb_class2name(mod), rb_id2name(id));
-    return Qnil;		/* not reached */
+    return val;
 }
 
 static int

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]