[#109095] [Ruby master Misc#18888] Migrate ruby-lang.org mail services to Google Domains and Google Workspace — "shugo (Shugo Maeda)" <noreply@...>
Issue #18888 has been reported by shugo (Shugo Maeda).
16 messages
2022/06/30
[ruby-core:108856] [Ruby master Bug#18767] IO.foreach hangs up when passes limit=0
From:
"andrykonchin (Andrew Konchin)" <noreply@...>
Date:
2022-06-11 11:17:46 UTC
List:
ruby-core #108856
Issue #18767 has been updated by andrykonchin (Andrew Konchin).
I agree that the current behaviour completely makes sense.
The point is that there are other IO methods (that read multiple lines) which don't except 0 as a limit. So it's more a consistency issue.
For instance `IO.readlines` and `IO#each_line`:
```ruby
File.open('Rakefile').each_line(0).to_a
# (irb):8:in `each_line': invalid limit: 0 for each_line (ArgumentError)
IO.readlines('Rakefile', 0)
# (irb):11:in `readlines': invalid limit: 0 for readlines (ArgumentError)
```
----------------------------------------
Bug #18767: IO.foreach hangs up when passes limit=0
https://bugs.ruby-lang.org/issues/18767#change-97936
* Author: andrykonchin (Andrew Konchin)
* Status: Rejected
* Priority: Normal
* ruby -v: 3.0.3
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`IO.foreach` behaves in an unexpected way in a corner case when passes 0 as a limit parameter. It never stops and hangs up.
```ruby
IO.foreach('file.txt', 0) { |s| p s }
""
""
""
""
""
""
""
""
""
""
```
Expected behavior - to raise ArgumentError "invalid limit: 0" like it does the `IO.readlines` method.
I observe this behavior on 2.6, 2.7, and 3.0. Didn't check on 3.1 and master though.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>