Possible fix, and a new bug for [Re: self-hosting repo available]

Andrew Bennetts andrew at canonical.com
Mon Apr 11 10:55:56 BST 2005


On Mon, Apr 11, 2005 at 11:15:50AM +0200, Erik Bågfors wrote:
> Ok, found out what caused this.  It's the 'å' in my last name in
> bzrlib.osutils.username().  By doing EMAIL="Erik Bagfors
> <erik at bagfors.nu>" it works.  But that's not my name :)
> 
> Some UTF8 problems here.  My system is all UTF8 (inclu /etc/passwd).

Here's a possible fix, with hackish test-case... except that the diff seems to
be broken... bzr diff has trouble with files that don't end with newlines,
maybe?  This is clearly a little broken:

    -echo "tests completed ok" >&3+# check that bzr copes with non-ascii BZREMAIL settings

andrew at trogdor ~/code/bzr.dev $ ./bzr diff
*** modified file 'bzrlib/osutils.py'
--- bzrlib/osutils.py
+++ bzrlib/osutils.py
@@ -18,6 +18,7 @@

 import os, types, re, time
 from stat import S_ISREG, S_ISDIR, S_ISLNK, ST_MODE, ST_SIZE
+import locale

 from errors import bailout, BzrError
 from trace import mutter
@@ -141,6 +142,10 @@

     :todo: Cope without pwd module, which is only on unix.
     """
+    # Whatever _username() returns, try to turn it into a unicode object.
+    return _username().decode(locale.getpreferredencoding())
+
+def _username():
     e = os.environ.get('BZREMAIL') or os.environ.get('EMAIL')
     if e: return e


*** modified file 'test.sh'
--- test.sh
+++ test.sh
@@ -125,4 +125,7 @@
 [ `bzr revno` = 2 ]


-echo "tests completed ok" >&3+# check that bzr copes with non-ascii BZREMAIL settings
+BZREMAIL=`python -c "import sys, locale; sys.stdout.write(unichr(0xc3).encode(locale.getpreferredencoding()))"` bzr help
+
+echo "tests completed ok" >&3


Regards,

-Andrew.





More information about the bazaar mailing list