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:
parent
5b94fc9601
commit
220d2a7182
@ -557,7 +557,9 @@ class TestThread < Test::Unit::TestCase
|
|||||||
assert_equal(3, t.fetch("qux") {x = 3})
|
assert_equal(3, t.fetch("qux") {x = 3})
|
||||||
assert_equal(3, x)
|
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
|
ensure
|
||||||
t.kill if t
|
t.kill if t
|
||||||
end
|
end
|
||||||
|
2
thread.c
2
thread.c
@ -3168,7 +3168,7 @@ rb_thread_fetch(int argc, VALUE *argv, VALUE self)
|
|||||||
return rb_yield(key);
|
return rb_yield(key);
|
||||||
}
|
}
|
||||||
else if (argc == 1) {
|
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 {
|
else {
|
||||||
return argv[1];
|
return argv[1];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user