From 25d8e7a119d3a96f8e782a87be8ba1ac557fa28d Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 6 Mar 2005 02:41:15 +0000 Subject: [PATCH] * lib/pp.rb (File::Stat#pretty_print): Etc.getpwuid and Etc.getgrgid may return nil. [ruby-talk:129826] reported by Daniel Berger. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ lib/pp.rb | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21414ece3d..dfb242daaa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Mar 6 11:36:37 2005 Tanaka Akira + + * lib/pp.rb (File::Stat#pretty_print): Etc.getpwuid and Etc.getgrgid + may return nil. [ruby-talk:129826] + reported by Daniel Berger. + Sun Mar 6 06:34:31 2005 GOTOU Yuuzou * ext/openssl/ossl_ssl.c (ossl_start_ssl): should wait for that diff --git a/lib/pp.rb b/lib/pp.rb index 756dce6f51..7cbbd8a0c0 100644 --- a/lib/pp.rb +++ b/lib/pp.rb @@ -407,19 +407,23 @@ class File q.group { q.text "uid="; q.pp self.uid begin - name = Etc.getpwuid(self.uid).name - q.breakable; q.text "(#{name})" + pw = Etc.getpwuid(self.uid) rescue ArgumentError end + if pw + q.breakable; q.text "(#{pw.name})" + end } q.comma_breakable q.group { q.text "gid="; q.pp self.gid begin - name = Etc.getgrgid(self.gid).name - q.breakable; q.text "(#{name})" + gr = Etc.getgrgid(self.gid) rescue ArgumentError end + if gr + q.breakable; q.text "(#{gr.name})" + end } q.comma_breakable q.group {