Branch: refs/heads/master Home: https://github.com/MacRuby/MacRuby Commit: 37bf494f082e41b4bb75c4de697a6653aea76acf https://github.com/MacRuby/MacRuby/commit/37bf494f082e41b4bb75c4de697a6653ae... Author: Watson <watson1978@gmail.com> Date: 2011-05-12 (Thu, 12 May 2011) Changed paths: M io.c Log Message: ----------- IO.readlines (and family) will raise a TypeError when was passed Object which has not to_str method. Test Script: {{{ require 'test/unit/assertions.rb' include Test::Unit::Assertions File.open("/tmp/foo", "w") {|f| f.puts "foo" f.puts "bar" } sep = Object.new assert_raise(TypeError){ IO.readlines("/tmp/foo", sep, 10) } assert_raise(TypeError){ IO.readlines("/tmp/foo", sep) } def sep.to_str; "\n"; end ary = IO.readlines("/tmp/foo", sep, 10) assert_equal(["foo\n", "bar\n"], ary) ary = IO.readlines("/tmp/foo", sep) assert_equal(["foo\n", "bar\n"], ary) ary = IO.readlines("/tmp/foo", 10) assert_equal(["foo\n", "bar\n"], ary) puts :ok }}}