Checks if #to_ary raises an exception

Raises the original exception when #to_ary raises one when yielding a
block

When the argument is a splat, #to_ary is not called in MRI 1.9

Fix #2347