StringIO#{readlines(0), each_line(0)}が無限ループする

$B%a!<%k$N%?%$%H%kDL$j$J$N$G$9$,!"(B
StringIO#{readlines, each_line} $B$N(B limit $B0z?t$K(B 0 $B$rEO$9$H(B
$BL58B%k!<%W$,H/@8$7$^$9!#(B
$B8=>]$O(B ruby1.9.2-p180 $B$*$h$S(B trunk head $B$G3NG’$7$F$$$^$9!#(B

$ ruby -r stringio -e ‘io = StringIO.new(“foo\nbar”); io.readlines(0)’
$ ruby -r stringio -e ‘io = StringIO.new(“foo\nbar”); io.each_line(0){}’

http://redmine.ruby-lang.org/issues/4024
$B$HN`;w$NIT6q9g$+$H;W$$Js9p$$$?$7$^$9!#(B

r31252 [email protected]$7$^$7$?!#(B
$BJs9p$"$j$,$H$&$4$6$$$^$7$?!#(B

http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=31252

2011/4/8 Watson [email protected]:

$B$$$^$$$G$9!#(B

From: “Shota F. (sora_h)” <sorah_at_tubusu.net>
Date: Sat, 9 Apr 2011 22:03:07 +0900

r31252 [email protected]$7$^$7$?!#(B
$BJs9p$"$j$,$H$&$4$6$$$^$7$?!#(B

http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=31252

$ ruby -rstringio -ve ‘StringIO.new.each_line(0)’
ruby 1.9.3dev (2011-04-09 trunk 31252) [x86_64-linux]
-e:1:in each_line': invalid limit: 0 for readlines (ArgumentError) from -e:1:in
$ ruby -rstringio -ve ‘StringIO.new.lines(0)’
ruby 1.9.3dev (2011-04-09 trunk 31252) [x86_64-linux]
-e:1:in lines': invalid limit: 0 for readlines (ArgumentError) from -e:1:in

$B%(%i!<%a%C%;!<%8$O(B each_line/lines $B$KBP$7$F$b(B readlines
$B$G$$$$$s$G$7$g(B
$B$&$+!)(BIO $B$NJ}$O!"(Beach_line/lines $B$KBP$7$F(B each_line
$B$HI=<($7$^$9!#(B

$ ruby -ve ‘IO.pipe{|i,| i.each_line(0).to_a}’
ruby 1.9.3dev (2011-04-09 trunk 31252) [x86_64-linux]
-e:1:in each_line': invalid limit: 0 for each_line (ArgumentError) from -e:1:ineach’
from -e:1:in to_a' from -e:1:inblock in ’
from -e:1:in pipe' from -e:1:in
$ ruby -ve ‘IO.pipe{|i,| i.lines(0).to_a}’
ruby 1.9.3dev (2011-04-09 trunk 31252) [x86_64-linux]
-e:1:in lines': invalid limit: 0 for each_line (ArgumentError) from -e:1:ineach’
from -e:1:in to_a' from -e:1:inblock in ’
from -e:1:in pipe' from -e:1:in

$B$"$H!"(BIO $B$NJ}$O!"(B0 [email protected]$1$G$O(B Enumerator
$B$,JV$C$F%(%i!<$K$J$i$J(B
$B$$$N$G!"$A$g$C$H5sF0$,0c$&$J!"$H;W$$$^$7$?!#(B

$ ruby -ve ‘p IO.pipe{|i,| i.each_line(0)}’
ruby 1.9.3dev (2011-04-09 trunk 31252) [x86_64-linux]
#<Enumerator: #IO:(closed):each_line(0)>

sora_h$B$G$9!#(B

2011/4/9 Nobuhiro IMAI [email protected]:

$B%(%i!<%a%C%;!<%8$O(B each_line/lines $B$KBP$7$F$b(B readlines
$B$G$$$$$s$G$7$g(B
$B$&$+!)(BIO $B$NJ}$O!"(Beach_line/lines $B$KBP$7$F(B each_line
$B$HI=<($7$^$9!#(B
(snip)
$B$"$H!"(BIO $B$NJ}$O!"(B0 [email protected]$1$G$O(B Enumerator
$B$,JV$C$F%(%i!<$K$J$i$J(B
$B$$$N$G!"$A$g$C$H5sF0$,0c$&$J!"$H;W$$$^$7$?!#(B

$BN>J}$H$b(B r31253 [email protected]$7$^$7$?!#(B
$B;XE&$"$j$,$H$&$4$6$$$^$7$?!#(B

http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=31253

$B$^$D$b$H(B $B$f$-$R$m$G$9(B

In message “Re: [ruby-dev:43394] Re: StringIO#{readlines(0),
each_line(0)}$B$,L58B%k!<%W$9$k(B”
on Sat, 9 Apr 2011 23:08:58 +0900, Nobuhiro IMAI [email protected]
writes:

|$B%(%i!<%a%C%;!<%8$O(B each_line/lines $B$KBP$7$F$b(B readlines
$B$G$$$$$s$G$7$g(B
|$B$&$+!)(BIO $B$NJ}$O!"(Beach_line/lines $B$KBP$7$F(B each_line
$B$HI=<($7$^$9!#(B

$B$"$H!"%<%m%A%’%C%/$,(B FIXNUM $B$+$D(B 0 $B$G%A%’%C%/$7$F$^$9$,!“87(B
$BL)[email protected]$&$H(BBignum$B$N(B0$B$H$+$b$”$k$N$G!"(BIO$BF1MM(BNUM2LONG$B$G(B0$B$KJQ49$7(B
$B$?J}$,NI$$$H;W$$$^$9!#(B

$B$4BP1~$"$j$,$H$&$4$6$$$^$9!#(B

$B#[email protected]$$K$J$k$N$G$9$,!"(BFIX2INT$B$r;HMQ$5$l$k$H0J2<$N$h$&$J%1!<%9$KBP1~$G$-$J$$$+$H;W$o$l$^$9!#(B
$ ruby -r stringio -e ‘o = Object.new; def o.to_int; 0; end;
StringIO.new.readlines(o)’

2011$BG/(B4$B7n(B9$BF|(B23:29 Shota F. (sora_h)
[email protected]:

sora_h$B$G$9!#(B
[email protected]$K0lEY%3%_%C%H$7$F$7$^$$$^$7$?!#(B

2011/4/9 Yukihiro M. [email protected]:

$B$"$H!"%<%m%A%’%C%/$,(B FIXNUM $B$+$D(B 0 $B$G%A%’%C%/$7$F$^$9$,!"87(B

$BL)[email protected]$&$H(BBignum$B$N(B0$B$H$+$b$"$k$N$G!"(BIO$BF1MM(BNUM2LONG$B$G(B0$B$KJQ49$7(B

$B$?J}$,NI$$$H;W$$$^$9!#(B

  • if(argc > 0 && TYPE(argv[argc-1]) == T_FIXNUM &&
  •   FIX2INT(argv[argc-1]) == 0) {
    
  • if(argc > 0 && !NIL_P(argv[argc-1]) && TYPE(argv[argc-1]) !=
    T_STRING &&
  •   NUM2LONG(argv[argc-1]) == 0) {
    

$B$3$s$J46$8$GNI$$$G$7$g$&$+!#(B
NUM2LONG$B$GJQ492DG=!"$H$$$&$3$H$r3NG’$9$kNI$$J}K!$,$o$+$i$J$$$N$G!"$H$j$"$($:%3%_%C%H$9$k$N$O95$($^$9!#(B

$BNI$$J}K!$,$"$C$?$i65$($F$/[email protected]$5$$!#(B

$BF1$8FbMF$r!"(B[ruby-dev:43395] $B$G;XE&$5$l$^$7$?!#(B
$B$=$l$KBP$9$kJV?.$O(B [ruby-dev:43398] $B$G$9!#(B

$B$^$?!"$=$3$GKvHx$K$+$$$?>r7oJ8$N2~A1$r(BIRC$B$G65$([email protected]$r%3%_%C%H$7$^$7$?!#(B

http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=31254

2011/4/9 Watson [email protected]:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs