Project

General

Profile

Bug #15199

scanf.rb broken with io from IO.pipe (MinGW or Windows?)

Added by MSP-Greg (Greg L) 12 months ago. Updated 24 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:89271]

Description

scanf.rb seems to be broken when using an io from a pipe.

The following code is used in IO#scanf:

link: https://github.com/ruby/ruby/blob/d4b0efc010a45e904ecdad2dd74374b5c74e61e3/lib/scanf.rb#L661-L664

begin
  seek(start_position + matched_so_far, IO::SEEK_SET)
rescue Errno::ESPIPE
end

if the rescue statement is replaced with:

rescue Errno::ESPIPE, Errno::EINVAL

It seems to work. I assume at some point, a 'pipe' io raised an Errno::ESPIPE error when called with #seek, but trunk & 2.3 respond with Errno::EINVAL...


Related issues

Related to Ruby master - Bug #12230: Wrong exception raised when IO.read from a pipe is passed an offset on WindowsClosedActions

Associated revisions

Revision d118c84b
Added by jeremyevans (Jeremy Evans) 3 months ago

Fix IO#scanf on pipes on Windows

IO.seek on a pipe on Windows raises Errno::EINVAL instead of
Errno::ESPIPE.

Fixes Ruby Bug #15199

Revision 662a3ca8
Added by usa (Usaku NAKAMURA) 24 days ago

merge revision(s) d118c84b0b9110462e479487ffaf175a75e5718e: [Backport #15199]

    Fix IO#scanf on pipes on Windows

    IO.seek on a pipe on Windows raises Errno::EINVAL instead of
    Errno::ESPIPE.

    Fixes Ruby Bug #15199

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@67754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 67754
Added by usa (Usaku NAKAMURA) 24 days ago

merge revision(s) d118c84b0b9110462e479487ffaf175a75e5718e: [Backport #15199]

Fix IO#scanf on pipes on Windows

IO.seek on a pipe on Windows raises Errno::EINVAL instead of
Errno::ESPIPE.

Fixes Ruby Bug #15199

History

#1

Updated by MSP-Greg (Greg L) 12 months ago

  • Subject changed from scanf.rb broken with io from IO.pipe to scanf.rb broken with io from IO.pipe (MinGW or Windows?)
#2

Updated by nagachika (Tomoyuki Chikanaga) 11 months ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED

Updated by jeremyevans0 (Jeremy Evans) 3 months ago

I've tested on Windows and confirmed this is a bug.

I added a pull request upstream to fix this: https://github.com/ruby/scanf/pull/4

If nobody has objections, I'll merge this in about a week.

Updated by usa (Usaku NAKAMURA) 24 days ago

  • Backport changed from 2.3: REQUIRED, 2.4: REQUIRED, 2.5: REQUIRED to 2.3: REQUIRED, 2.4: REQUIRED, 2.5: DONE

ruby_2_5 r67754 merged revision(s) d118c84b0b9110462e479487ffaf175a75e5718e.

#6

Updated by nobu (Nobuyoshi Nakada) 23 days ago

  • Related to Bug #12230: Wrong exception raised when IO.read from a pipe is passed an offset on Windows added

Also available in: Atom PDF