Skip to content

StringIO#gets("\r\n", 10) returns an extra \n #3856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
eregon opened this issue May 8, 2025 · 0 comments
Open

StringIO#gets("\r\n", 10) returns an extra \n #3856

eregon opened this issue May 8, 2025 · 0 comments

Comments

@eregon
Copy link
Member

eregon commented May 8, 2025

From ruby/net-imap#470 (comment) by @nevans

@eregon here's the issue I saw with IO#gets(CRLF, limit):

#!/usr/bin/env ruby

puts ?=*72
puts "Ruby Engine:   #{RUBY_ENGINE} #{RUBY_ENGINE_VERSION}"

require 'bundler/inline'
gemfile do
  gem "stringio", ">= 3.1.7"
end
require "stringio"
puts "Using StringIO #{StringIO::VERSION}"
io = StringIO.new("123456789\r\n123456789\r\n")
pp stringio: io.gets("\r\n", 10)

r, w = IO.pipe
w.write "123456789\r\n123456789\r\n"
w.close
pp io_pipe: r.gets("\r\n", 10)

__END__
$ ruby test.rb && RBENV_VERSION=truffleruby-24.2.1 ruby test.rb
========================================================================
Ruby Engine:   ruby 3.4.2
Using StringIO 3.1.7
{stringio: "123456789\r"}
{io_pipe: "123456789\r"}
========================================================================
Ruby Engine:   truffleruby 24.2.1
Using StringIO 3.0.1
{:stringio=>"123456789\r\n"}
{:io_pipe=>"123456789\r"}

I didn't make a TruffleRuby ticket for this. I'm guessing this is already a known issue, given that it silently failed to use a newer version of StringIO (even after I manually gem installed it). And it looks like it only affects the test which uses StringIO and probably doesn't affect real IO.

@eregon eregon changed the title StringIO#.gets("\r\n", 10) returns an extra \n StringIO#gets("\r\n", 10) returns an extra \n May 8, 2025
@andrykonchin andrykonchin self-assigned this May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants