diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-21 10:20:55 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-21 10:20:55 +0000 |
| commit | 33b4dc79d31e0df9a64a82e472892a552b1f0d37 (patch) | |
| tree | 8d3dea72e352f38788ae3c35b32b743e2b45d1bd | |
| parent | 39070cabae3d911397c324323d6b7f29532f4915 (diff) | |
| download | ruby-33b4dc79d31e0df9a64a82e472892a552b1f0d37.tar.gz ruby-33b4dc79d31e0df9a64a82e472892a552b1f0d37.tar.xz ruby-33b4dc79d31e0df9a64a82e472892a552b1f0d37.zip | |
* file.c (rb_stat_inspect): don't raise if self is not initialized.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | file.c | 6 | ||||
| -rw-r--r-- | test/ruby/test_file.rb | 1 |
3 files changed, 11 insertions, 0 deletions
@@ -1,3 +1,7 @@ +Thu Aug 21 19:20:25 2008 Tanaka Akira <akr@fsij.org> + + * file.c (rb_stat_inspect): don't raise if self is not initialized. + Thu Aug 21 19:17:02 2008 Tanaka Akira <akr@fsij.org> * process.c (pst_pid): use rb_attr_get to avoid warning on @@ -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 26b29785a..f6fcf89a1 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 |
