* load.c (rb_provide_feature): clarify error message for frozen

$LOADED_FEATURES.  based on a patch from Run Paint Run Run at
  [ruby-core:31913].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-08-29 03:51:39 +00:00
Родитель 7e53b3b6ba
Коммит b9432e7630
3 изменённых файлов: 17 добавлений и 0 удалений

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

@ -1,3 +1,9 @@
Sun Aug 29 12:51:33 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* load.c (rb_provide_feature): clarify error message for frozen
$LOADED_FEATURES. based on a patch from Run Paint Run Run at
[ruby-core:31913].
Sun Aug 29 12:19:58 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* load.c (load_failed): should honor encoding. [ruby-core:31915]

4
load.c
Просмотреть файл

@ -250,6 +250,10 @@ rb_feature_provided(const char *feature, const char **loading)
static void
rb_provide_feature(VALUE feature)
{
if (OBJ_FROZEN(get_loaded_features())) {
rb_raise(rb_eRuntimeError,
"$LOADED_FEATURES is frozen; cannot append feature");
}
rb_ary_push(get_loaded_features(), feature);
}

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

@ -310,4 +310,11 @@ class TestRequire < Test::Unit::TestCase
}
}
end
def test_frozen_loaded_features
bug3756 = '[ruby-core:31913]'
assert_in_out_err(['-e', '$LOADED_FEATURES.freeze; require "ostruct"'], "",
[], /\$LOADED_FEATURES is frozen; cannot append feature \(RuntimeError\)$/,
bug3756)
end
end