[前][次][番号順一覧][スレッド一覧]

ruby-changes:74403

From: Yusuke <ko1@a...>
Date: Wed, 9 Nov 2022 12:25:52 +0900 (JST)
Subject: [ruby-changes:74403] c3de7a3c58 (master): Make pending_interrupt?(Exception) work

https://git.ruby-lang.org/ruby.git/commit/?id=c3de7a3c58

From c3de7a3c58bf9a138ff8720ed56c0045d2b8e01d Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Tue, 8 Nov 2022 13:35:37 +0900
Subject: Make pending_interrupt?(Exception) work

A patch from katsu (Katsuhiro Ueno)

[Bug #19110]
---
 test/ruby/test_thread.rb | 8 ++++++++
 thread.c                 | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index f6156a16fd..8ca23e7d02 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -1515,4 +1515,12 @@ q.pop https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L1515
       end
     };
   end
+
+  def test_pending_interrupt?
+    t = Thread.handle_interrupt(Exception => :never) { Thread.new { Thread.stop } }
+    t.raise(StandardError)
+    assert_equal(true, t.pending_interrupt?)
+    assert_equal(true, t.pending_interrupt?(Exception))
+    assert_equal(false, t.pending_interrupt?(ArgumentError))
+  end
 end
diff --git a/thread.c b/thread.c
index d8925e618e..624c070877 100644
--- a/thread.c
+++ b/thread.c
@@ -1922,7 +1922,7 @@ rb_threadptr_pending_interrupt_include_p(rb_thread_t *th, VALUE err) https://github.com/ruby/ruby/blob/trunk/thread.c#L1922
     int i;
     for (i=0; i<RARRAY_LEN(th->pending_interrupt_queue); i++) {
         VALUE e = RARRAY_AREF(th->pending_interrupt_queue, i);
-        if (rb_class_inherited_p(e, err)) {
+        if (rb_obj_is_kind_of(e, err)) {
             return TRUE;
         }
     }
-- 
cgit v1.2.3


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]