[#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:108830] [Ruby master Bug#18767] IO.foreach hangs up when passes limit=0
From:
"mame (Yusuke Endoh)" <noreply@...>
Date:
2022-06-09 09:48:02 UTC
List:
ruby-core #108830
Issue #18767 has been updated by mame (Yusuke Endoh).
Status changed from Open to Rejected
I believe this is not a bug. I don't think the current behavior is very useful, but I don't think it is so problematic either. Considering the following example, the behavior is consistent in a sense.
```
irb(main):001:0> File.write("foo.txt", [*?A..?Z].join)
=> 26
irb(main):002:0> File.foreach("foo.txt", 4).take(4)
=> ["ABCD", "EFGH", "IJKL", "MNOP"]
irb(main):003:0> File.foreach("foo.txt", 3).take(4)
=> ["ABC", "DEF", "GHI", "JKL"]
irb(main):004:0> File.foreach("foo.txt", 2).take(4)
=> ["AB", "CD", "EF", "GH"]
irb(main):005:0> File.foreach("foo.txt", 1).take(4)
=> ["A", "B", "C", "D"]
irb(main):006:0> File.foreach("foo.txt", 0).take(4)
=> ["", "", "", ""]
```
@andrykonchin If you really want to change this behavior, please open a feature request with an explanation of a real-world use case.
----------------------------------------
Bug #18767: IO.foreach hangs up when passes limit=0
https://bugs.ruby-lang.org/issues/18767#change-97906
* 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>