From: brian ford Date: 2011-08-30T07:34:56+09:00 Subject: [ruby-core:39190] Re: [Ruby 1.9 - Bug #5237] IO.copy_stream calls #read on an object infinitely many times On Sat, Aug 27, 2011 at 10:55 PM, KOSAKI Motohiro wrote: >>> The class that implements an IO#read-like method without clearing >>> the destination buffer on EOF is arguably broken, but infinite >>> looping is bad, I think. >> >> Ah, you are right, it really should replace buffer with "" (according >> to the code) and return nil according to the docs. Seems more than a >> little weird, however, to empty the buffer to signal EOF, especially >> since the buffer argument is optional. > > I'm curious. Which doc do you talk about? The RDoc, which refers to returning nil or "" depending on what arguments are passed. For the case here, it does not matter what value is returned. The only way to not loop infinitely is to set the buffer to "". > >