Project

General

Profile

Bug #18743 ยป 01-Recreate-stacktrace-enumerator.patch

marcper (Marcelo Pereira), 10/23/2022 01:09 PM

View differences:

enumerator.c
{
VALUE curr, vs;
if (e->stop_exc)
if (e->stop_exc) {
VALUE result = rb_ivar_get(e->stop_exc, id_result);
e->stop_exc = rb_exc_new2(rb_eStopIteration, "iteration reached an end");
rb_ivar_set(e->stop_exc, id_result, result);
rb_exc_raise(e->stop_exc);
}
curr = rb_fiber_current();
test/ruby/test_enumerator.rb
assert_equal(res, exc.result)
end
def test_stopiteration_rescue
e = [1].each
res = e.each {}
e.next
e.peek rescue nil
e.next rescue nil
exc = assert_raise(StopIteration) { e.peek }
assert_include(exc.backtrace.first, "test_enumerator.rb:#{__LINE__-1}:")
assert_equal(res, exc.result)
exc = assert_raise(StopIteration) { e.next }
assert_include(exc.backtrace.first, "test_enumerator.rb:#{__LINE__-1}:")
assert_equal(res, exc.result)
end
def test_next_values
o = Object.new
def o.each
    (1-1/1)