зеркало из https://github.com/github/ruby.git
Fix KeyError#{key,receiver} of Thread#fetch
[ruby-core:84508] [Bug #14247] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5b94fc9601
Коммит
220d2a7182
|
@ -557,7 +557,9 @@ class TestThread < Test::Unit::TestCase
|
|||
assert_equal(3, t.fetch("qux") {x = 3})
|
||||
assert_equal(3, x)
|
||||
|
||||
assert_raise(KeyError) {t.fetch(:qux)}
|
||||
e = assert_raise(KeyError) {t.fetch(:qux)}
|
||||
assert_equal(:qux, e.key)
|
||||
assert_equal(t, e.receiver)
|
||||
ensure
|
||||
t.kill if t
|
||||
end
|
||||
|
|
2
thread.c
2
thread.c
|
@ -3168,7 +3168,7 @@ rb_thread_fetch(int argc, VALUE *argv, VALUE self)
|
|||
return rb_yield(key);
|
||||
}
|
||||
else if (argc == 1) {
|
||||
rb_raise(rb_eKeyError, "key not found: %"PRIsVALUE, key);
|
||||
rb_key_err_raise(rb_sprintf("key not found: %+"PRIsVALUE, key), self, key);
|
||||
}
|
||||
else {
|
||||
return argv[1];
|
||||
|
|
Загрузка…
Ссылка в новой задаче