Actions
Bug #18769
closedStringIO#each hangs up on some input with `chomp: true`
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.3
Description
The mentioned StringIO method #each
(as well as #readlines
and #each_line
) may hang up when passed a separator and chomp: true
:
require 'stringio'
StringIO.new('a||b||c').each("||", chomp: true) { |s| p s }
""
""
""
""
""
""
""
The same way behave other two methods:
StringIO.new('a||b||c').readlines("||", chomp: true)
StringIO.new('a||b||c').each_line("||", chomp: true) { |s| p s }
Updated by jeremyevans0 (Jeremy Evans) almost 3 years ago
I've submitted a pull request to fix this: https://github.com/ruby/stringio/pull/30
Updated by jeremyevans (Jeremy Evans) almost 3 years ago
- Status changed from Open to Closed
Applied in changeset git|1f82269f4e1bf037e3e5504c6071b905f26fec6f.
[ruby/stringio] Fix each with multiple character string and chomp
Previously, this could result in an infinite loop. Always update
the e pointer in this case, setting w when chomping so the chomped
data is not included in the output.
Fixes [Bug #18769]
Actions
Like0
Like0Like0