Project

General

Profile

Actions

Bug #2380

closed

IO#eof? behavior different with 1.9.1p243-mingw32 than other platforms

Added by undees (Ian Dees) over 14 years ago. Updated about 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32]
Backport:
[ruby-core:26788]

Description

=begin
In the following code:

open('somefile.txt', 'r') do |f|
until f.eof? do
raise 'nil character' if f.getc.nil?
end
end

The code runs without error in both Ruby 1.8 and 1.9 on Ubuntu, and 1.8 on Win32. The call to eof? returns true and prevents getc from being called in a situation that would return nil. But Ruby 1.9 on Win32 throws the "nil character" exception shown.

This difference disrupts tools like autospec, which opens a pipe to a subprocess and reads the results character by character.

Luis Lavena offers the following observations after his own tests of the issue:

"I just tested exact same example with 1.8.6 without errors (somefile containing both LF or CRLF).... I can confirm this fails with 1.9.1 patchelvel 243, but works with patchlevel 129, which indicates a regression in Ruby."
=end


Related issues 1 (0 open1 closed)

Is duplicate of Backport191 - Backport #2168: File.eof? does not work correctlyClosedyugui (Yuki Sonoda)10/01/2009Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0