[Pkg-bazaar-commits] ./bzr/unstable r25: cope when gecos field doesn't have a comma

Martin Pool mbp at sourcefrog.net
Fri Apr 10 07:25:27 UTC 2009


------------------------------------------------------------
revno: 25
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Sat 2005-03-12 18:16:39 +1100
message:
  cope when gecos field doesn't have a comma
  
  reported by ysaito, rooneg -- thanks
modified:
  bzrlib/osutils.py
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2005-03-11 23:19:53 +0000
+++ b/bzrlib/osutils.py	2005-03-12 07:16:39 +0000
@@ -135,7 +135,12 @@
         import pwd
         uid = os.getuid()
         w = pwd.getpwuid(uid)
-        realname, junk = w.pw_gecos.split(',', 1)
+        gecos = w.pw_gecos
+        comma = gecos.find(',')
+        if comma == -1:
+            realname = gecos
+        else:
+            realname = gecos[:comma]
         return '%s <%s@%s>' % (realname, w.pw_name, socket.getfqdn())
     except ImportError:
         pass



More information about the Pkg-bazaar-commits mailing list