ruby-changes:49391
From: kazu <ko1@a...>
Date: Thu, 28 Dec 2017 09:00:20 +0900 (JST)
Subject: [ruby-changes:49391] kazu:r61507 (trunk): Fix KeyError#{key, receiver} of Thread#fetch
kazu 2017-12-28 09:00:05 +0900 (Thu, 28 Dec 2017) New Revision: 61507 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61507 Log: Fix KeyError#{key,receiver} of Thread#fetch [ruby-core:84508] [Bug #14247] Modified files: trunk/test/ruby/test_thread.rb trunk/thread.c Index: test/ruby/test_thread.rb =================================================================== --- test/ruby/test_thread.rb (revision 61506) +++ test/ruby/test_thread.rb (revision 61507) @@ -557,7 +557,9 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L557 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 Index: thread.c =================================================================== --- thread.c (revision 61506) +++ thread.c (revision 61507) @@ -3168,7 +3168,7 @@ rb_thread_fetch(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/thread.c#L3168 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]; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/