From c186fdb90bfecb9ecc9a001796a19efca401dc4c Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 8 Aug 2007 07:07:03 +0000 Subject: * enumerator.c (enumerator_next_p): should check correctly even when e.next has not been called before. * enumerator.c (enumerator_next): raise StopIteration (name taken from Python) instead of IndexError. * enum.c (enum_zip): catch StopIteration exception. * enumerator.c (enumerator_with_index): return Enumerator if no block is given. * test/ruby/test_iterator.rb (TestIterator::test_enumerator): add test for enumerators. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- enum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'enum.c') diff --git a/enum.c b/enum.c index fa58762463..d7f9f740c7 100644 --- a/enum.c +++ b/enum.c @@ -1411,7 +1411,7 @@ enum_zip(int argc, VALUE *argv, VALUE obj) RETURN_ENUMERATOR(obj, argc, argv); result = rb_block_given_p() ? Qnil : rb_ary_new(); memo = rb_node_newnode(NODE_MEMO, result, rb_ary_new4(argc, argv), obj); - rb_rescue2(zip_b, (VALUE)memo, 0, 0, rb_eIndexError, (VALUE)0); + rb_rescue2(zip_b, (VALUE)memo, 0, 0, rb_eStopIteration, (VALUE)0); return result; } -- cgit v1.2.3