[前][次][番号順一覧][スレッド一覧]

ruby-changes:7233

From: akr <ko1@a...>
Date: Thu, 21 Aug 2008 19:18:55 +0900 (JST)
Subject: [ruby-changes:7233] Ruby:r18752 (trunk): * process.c (pst_pid): use rb_attr_get to avoid warning on

akr	2008-08-21 19:18:38 +0900 (Thu, 21 Aug 2008)

  New Revision: 18752

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

  Log:
    * process.c (pst_pid): use rb_attr_get to avoid warning on
      Process::Status.allocate.pid.
      (pst_inspect): don't raise if self is not initialized.

  Modified files:
    trunk/ChangeLog
    trunk/process.c
    trunk/test/ruby/test_process.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18751)
+++ ChangeLog	(revision 18752)
@@ -1,3 +1,9 @@
+Thu Aug 21 19:17:02 2008  Tanaka Akira  <akr@f...>
+
+	* process.c (pst_pid): use rb_attr_get to avoid warning on
+	  Process::Status.allocate.pid.
+	  (pst_inspect): don't raise if self is not initialized.
+
 Thu Aug 21 19:05:40 2008  Tanaka Akira  <akr@f...>
 
 	* io.c (io_extract_encoding_option): if internal encoding is not
Index: process.c
===================================================================
--- process.c	(revision 18751)
+++ process.c	(revision 18752)
@@ -271,7 +271,7 @@
 static VALUE
 pst_pid(VALUE st)
 {
-    return rb_iv_get(st, "pid");
+    return rb_attr_get(st, rb_intern("pid"));
 }
 
 static void
@@ -344,9 +344,13 @@
 {
     rb_pid_t pid;
     int status;
-    VALUE str;
+    VALUE vpid, str;
 
-    pid = NUM2LONG(pst_pid(st));
+    vpid = pst_pid(st);
+    if (NIL_P(vpid)) {
+        return rb_sprintf("#<%s: uninitialized>", rb_class2name(CLASS_OF(st)));
+    }
+    pid = NUM2LONG(vpid);
     status = PST2INT(st);
 
     str = rb_sprintf("#<%s: ", rb_class2name(CLASS_OF(st)));
Index: test/ruby/test_process.rb
===================================================================
--- test/ruby/test_process.rb	(revision 18751)
+++ test/ruby/test_process.rb	(revision 18752)
@@ -1001,4 +1001,7 @@
     assert(true == r || false == r)
   end
 
+  def test_pst_inspect
+    assert_nothing_raised { Process::Status.allocate.inspect }
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]