IO.read and IO.readlines do not take a block
--------------------------------------------

                 Key: JRUBY-3204
                 URL: http://jira.codehaus.org/browse/JRUBY-3204
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.1.5
            Reporter: John Fremlin
         Attachments: jruby-20081201-read-does-not-take-a-block.patch

puts IO.read(__FILE__) { "fail" }

should ignore the fail. It does not and instead raises an exception because for 
some insane reason the block is passed to IO.open.

The attached patch fixes the problem but needs to be cleaned up.

The error message given is this

org.jruby.RubyIO:2801:in `read': java.lang.ClassCastException: 
org.jruby.RubyString cannot be cast to org.jruby.RubyIO
        from org.jruby.RubyIO$s_method_multi$RUBYINVOKER$read:-1:in `call'
        from org.jruby.runtime.callsite.CachingCallSite:290:in `cacheAndCall'
        from org.jruby.runtime.callsite.CachingCallSite:141:in `callIter'
        from read_minus_block_minus_test:1:in `__file__'
        from read_minus_block_minus_test:-1:in `__file__'
        from read_minus_block_minus_test:-1:in `load'
        from org.jruby.Ruby:560:in `runScript'
        from org.jruby.Ruby:463:in `runNormally'
        from org.jruby.Ruby:337:in `runFromMain'
        from org.jruby.Main:214:in `run'
        from org.jruby.Main:100:in `run'
        from org.jruby.Main:84:in `main'


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to