[MERGE] Two bug fixes
Michael Ellerman
michael at ellerman.id.au
Mon Mar 6 22:55:59 GMT 2006
On Mon, 6 Mar 2006 20:41, Robert Collins wrote:
> On Mon, 2006-03-06 at 11:55 +1100, Michael Ellerman wrote:
> > Hi folks,
> >
> > There's two bug fixes (#3452 and #32587) sitting on top of my random
> > stuff branch at:
> >
> > http://michael.ellerman.id.au/files/bzr/mpe
>
> Can you throw a patch-style-patch at me ?
First fix is just:
=== modified file 'a/bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py
+++ b/bzrlib/tests/test_config.py
@@ -542,8 +542,6 @@
self.my_config.post_commit())
-class TestLocationConfig(TestCaseInTempDir):
-
def get_location_config(self, location, global_config=None):
if global_config is None:
global_file = StringIO(sample_config_text)
The /etc/passwd encoding error message fix:
=== modified file 'a/bzrlib/config.py'
--- a/bzrlib/config.py
+++ b/bzrlib/config.py
@@ -524,8 +524,15 @@
import pwd
uid = os.getuid()
w = pwd.getpwuid(uid)
- gecos = w.pw_gecos.decode(bzrlib.user_encoding)
- username = w.pw_name.decode(bzrlib.user_encoding)
+
+ try:
+ gecos = w.pw_gecos.decode(bzrlib.user_encoding)
+ username = w.pw_name.decode(bzrlib.user_encoding)
+ except UnicodeDecodeError:
+ # We're using pwd, therefore we're on Unix, so /etc/passwd is ok.
+ raise errors.BzrError("Can't decode username in " \
+ "/etc/passwd as %s." % bzrlib.user_encoding)
+
comma = gecos.find(',')
if comma == -1:
realname = gecos
@@ -536,7 +543,11 @@
except ImportError:
import getpass
- realname = username = getpass.getuser().decode(bzrlib.user_encoding)
+ try:
+ realname = username = getpass.getuser().decode(bzrlib.user_encoding)
+ except UnicodeDecodeError:
+ raise errors.BzrError("Can't decode username as %s." % \
+ bzrlib.user_encoding)
return realname, (username + '@' + socket.gethostname())
cheers
More information about the bazaar
mailing list