mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Make pending_interrupt?(Exception) work
A patch from katsu (Katsuhiro Ueno) [Bug #19110]
This commit is contained in:
parent
558137d5f3
commit
c3de7a3c58
Notes:
git
2022-11-09 03:25:53 +00:00
2 changed files with 9 additions and 1 deletions
|
@ -1515,4 +1515,12 @@ q.pop
|
||||||
end
|
end
|
||||||
};
|
};
|
||||||
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
|
end
|
||||||
|
|
2
thread.c
2
thread.c
|
@ -1922,7 +1922,7 @@ rb_threadptr_pending_interrupt_include_p(rb_thread_t *th, VALUE err)
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<RARRAY_LEN(th->pending_interrupt_queue); i++) {
|
for (i=0; i<RARRAY_LEN(th->pending_interrupt_queue); i++) {
|
||||||
VALUE e = RARRAY_AREF(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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue