* variable.c (rb_mod_remove_const): do not change VM state when an

exception will occur.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-09-13 13:18:35 +00:00
Родитель 476a0355db
Коммит 283189807c
2 изменённых файлов: 19 добавлений и 14 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sun Sep 13 22:18:33 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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@nifty.ne.jp> Sun Sep 13 21:25:01 2009 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (oletypelib_get_libattr): some refactoring * ext/win32ole/win32ole.c (oletypelib_get_libattr): some refactoring

Просмотреть файл

@ -1596,8 +1596,6 @@ rb_mod_remove_const(VALUE mod, VALUE name)
VALUE val; VALUE val;
st_data_t v, n = id; st_data_t v, n = id;
rb_vm_change_state();
if (!rb_is_const_id(id)) { if (!rb_is_const_id(id)) {
rb_name_error(id, "`%s' is not allowed as a constant name", rb_id2name(id)); rb_name_error(id, "`%s' is not allowed as a constant name", rb_id2name(id));
} }
@ -1605,21 +1603,23 @@ rb_mod_remove_const(VALUE mod, VALUE name)
rb_raise(rb_eSecurityError, "Insecure: can't remove constant"); rb_raise(rb_eSecurityError, "Insecure: can't remove constant");
if (OBJ_FROZEN(mod)) rb_error_frozen("class/module"); if (OBJ_FROZEN(mod)) rb_error_frozen("class/module");
if (RCLASS_IV_TBL(mod) && st_delete(RCLASS_IV_TBL(mod), &n, &v)) { if (!RCLASS_IV_TBL(mod) || !st_delete(RCLASS_IV_TBL(mod), &n, &v)) {
val = (VALUE)v; if (rb_const_defined_at(mod, id)) {
if (val == Qundef) { rb_name_error(id, "cannot remove %s::%s",
autoload_delete(mod, id); rb_class2name(mod), rb_id2name(id));
val = Qnil;
} }
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_vm_change_state();
rb_class2name(mod), rb_id2name(id));
val = (VALUE)v;
if (val == Qundef) {
autoload_delete(mod, id);
val = Qnil;
} }
rb_name_error(id, "constant %s::%s not defined", return val;
rb_class2name(mod), rb_id2name(id));
return Qnil; /* not reached */
} }
static int static int