Closed stream (IOError)

test.rb:-

ObjectSpace.each_object {|obj| p obj}

ruby test.rb

"ObjectSpace.each_object {|obj| p obj}\n"
test.rb:1:in inspect': closed stream (IOError) from test.rb:1:inp’
from test.rb:1
from test.rb:1:in `each_object’
from test.rb:1

ruby 1.7.3 (2002-09-28)

anybody?

···


Ariff Abdullah
MyBSD Malaysia.
ariff@MyBSD.org.my
skywizard@time.net.my
http://staff.mybsd.org.my/skywizard
http://www.mybsd.org.my

Hi,

test.rb:-

ObjectSpace.each_object {|obj| p obj}

ruby test.rb

“ObjectSpace.each_object {|obj| p obj}\n”
test.rb:1:in inspect': closed stream (IOError) from test.rb:1:in p’
from test.rb:1
from test.rb:1:in `each_object’
from test.rb:1

ruby 1.7.3 (2002-09-28)

ObjectSpace.each_object yields any objects even disposed but
not GCed (in this case, perhaps the File used to load
“test.rb”), so there’s no guarantee that it never cause any
error.

But IO#inspect seems to not need to raise IOError.

$ ruby -e ‘p File.open(“x”, “w+”) {|f|f}’
-e:1:in inspect': closed stream (IOError) from -e:1:in p’
from -e:1

Index: io.c

···

At Mon, 30 Sep 2002 01:38:46 +0900, Ariff Abdullah wrote:

RCS file: /cvs/ruby/src/ruby/io.c,v
retrieving revision 1.160
diff -u -2 -p -r1.160 io.c
— io.c 25 Sep 2002 07:03:01 -0000 1.160
+++ io.c 30 Sep 2002 07:09:17 -0000
@@ -556,6 +556,6 @@ rb_io_inspect(obj)
char *buf, *cname;

  • GetOpenFile(obj, fptr);
  • if (!fptr->path) return rb_any_to_s(obj);
  • fptr = RFILE(rb_io_taint_check(obj))->fptr;
  • if (!fptr || !(fptr->f || fptr->f2) || !fptr->path) return rb_any_to_s(obj);
    cname = rb_class2name(CLASS_OF(obj));
    buf = ALLOCA_N(char, strlen(cname) + strlen(fptr->path) + 5);


Nobu Nakada

Hi,

···

In message “Re: closed stream (IOError)” on 02/09/30, nobu.nokada@softhome.net nobu.nokada@softhome.net writes:

But IO#inspect seems to not need to raise IOError.

OK, commit the fix, please.

						matz.