From: Daniel Berger Date: 2010-12-30T13:11:49+09:00 Subject: [ruby-core:34004] [Ruby 1.8-Bug#4225][Open] IO.foreach should only accept string arguments Bug #4225: IO.foreach should only accept string arguments http://redmine.ruby-lang.org/issues/show/4225 Author: Daniel Berger Status: Open, Priority: Normal Category: core, Target version: Ruby 1.8.7 ruby -v: ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin8.11.1] It looks like the IO.foreach method doesn't check its argument type first if no block is provided: fh = File.new('somefile.txt') IO.foreach(fh.fileno) # Or, IO.foreach(999999999) => # IO.foreach(fh.fileno){ |line| p line } TypeError: can't convert Fixnum into String I'd flip these two lines in io.c: RETURN_ENUMERATOR(self, argc, argv); SafeStringValue(fname); Otherwise, what am I enumerating? ---------------------------------------- http://redmine.ruby-lang.org