JRuby

FileTest methods only work with string arguments

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.1.1
  • Fix Version/s: JRuby 1.2
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    1

Description

FileTest methods in MRI work on filename strings or File objects, but in JRuby they only work with strings.

dudley@hiro jruby-trunk :> irb
>> FileTest.size(File.new('x','w+'))
=> 0

dudley@hiro jruby-trunk :> jirb
>> FileTest.size(File.new('x','w+'))
TypeError: can't convert File into String

Activity

Hide
Dudley Flanders added a comment -

Here's a patch that works for the specific case where you're passing in a File object (or anything that responds_to "path"). MRI calls to_io and then fstat on the IO object's file descriptor, so this isn't 100% compatible, but it is slightly closer than just accepting strings.

Show
Dudley Flanders added a comment - Here's a patch that works for the specific case where you're passing in a File object (or anything that responds_to "path"). MRI calls to_io and then fstat on the IO object's file descriptor, so this isn't 100% compatible, but it is slightly closer than just accepting strings.
Hide
Charles Oliver Nutter added a comment -

Confirmed, this is still broken. I think the approach we need is to add specs for where to_io is supposed to be called to the rubyspecs and fix from there. No one-shot hacks, sorry

Marking as broken in 1.1.1 to keep it fresh.

Show
Charles Oliver Nutter added a comment - Confirmed, this is still broken. I think the approach we need is to add specs for where to_io is supposed to be called to the rubyspecs and fix from there. No one-shot hacks, sorry Marking as broken in 1.1.1 to keep it fresh.
Hide
Charles Oliver Nutter added a comment -

Fixed in r8997. Also added some specs to RubySpec for at least File.size.

Show
Charles Oliver Nutter added a comment - Fixed in r8997. Also added some specs to RubySpec for at least File.size.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: