From: djberg96@... Date: 2014-05-18T00:33:41+00:00 Subject: [ruby-core:62650] [ruby-trunk - Bug #4225] IO.foreach should only accept string arguments Issue #4225 has been updated by Daniel Berger. Why do they defer? ---------------------------------------- Bug #4225: IO.foreach should only accept string arguments https://bugs.ruby-lang.org/issues/4225#change-46785 * Author: Daniel Berger * Status: Rejected * Priority: Normal * Assignee: * Category: core * Target version: * ruby -v: ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin8.11.1] * Backport: ---------------------------------------- It looks like the `IO.foreach` method doesn't check its argument type first if no block is provided: ~~~ruby 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: ~~~C RETURN_ENUMERATOR(self, argc, argv); SafeStringValue(fname); ~~~ Otherwise, what am I enumerating? -- https://bugs.ruby-lang.org/