diff --git a/ChangeLog b/ChangeLog index 6e2428b889..ea5aa674a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Aug 21 19:20:25 2008 Tanaka Akira + + * file.c (rb_stat_inspect): don't raise if self is not initialized. + Thu Aug 21 19:17:02 2008 Tanaka Akira * process.c (pst_pid): use rb_attr_get to avoid warning on diff --git a/file.c b/file.c index 970875f946..3c932cd2ec 100644 --- a/file.c +++ b/file.c @@ -671,6 +671,12 @@ rb_stat_inspect(VALUE self) {"ctime", rb_stat_ctime}, }; + struct stat* st; + Data_Get_Struct(self, struct stat, st); + if (!st) { + return rb_sprintf("#<%s: uninitialized>", rb_obj_classname(self)); + } + str = rb_str_buf_new2("#<"); rb_str_buf_cat2(str, rb_obj_classname(self)); rb_str_buf_cat2(str, " "); diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index 26b29785ab..f6fcf89a14 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -117,5 +117,6 @@ class TestFile < Test::Unit::TestCase def test_uninitialized assert_raise(TypeError) { File::Stat.allocate.readable? } + assert_nothing_raised { File::Stat.allocate.inspect } end end