Rev 3648: Provides a better default encoding on OSX. in http://bazaar.launchpad.net/%7Ebzr/bzr/osx_tests_fix

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Sep 8 08:56:36 BST 2008


At http://bazaar.launchpad.net/%7Ebzr/bzr/osx_tests_fix

------------------------------------------------------------
revno: 3648
revision-id: v.ladeuil+lp at free.fr-20080908075607-yqbmjnhhmzdjz61y
parent: v.ladeuil+lp at free.fr-20080908062742-mm7uf6zqjq45qhnt
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: osx_tests_fix
timestamp: Mon 2008-09-08 09:56:07 +0200
message:
  Provides a better default encoding on OSX.
  
  * bzrlib/osutils.py:
  (get_user_encoding): Provides 'utf-8' as default on OSX instead of
  'ascii' which even out own test suite doesn't like.
modified:
  bzrlib/osutils.py              osutils.py-20050309040759-eeaff12fbf77ac86
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2008-08-31 19:06:07 +0000
+++ b/bzrlib/osutils.py	2008-09-08 07:56:07 +0000
@@ -1404,9 +1404,19 @@
         return _cached_user_encoding
 
     if sys.platform == 'darwin':
-        # work around egregious python 2.4 bug
+        # python locale.getpreferredencoding() always return
+        # 'mac-roman' on darwin. That's a lie.
         sys.platform = 'posix'
         try:
+            if os.environ.get('LANG', None) is None:
+                # If LANG is not set, we end up with 'ascii', which is bad
+                # ('mac-roman' is more than ascii), so we set a default which
+                # will give us UTF-8 (which appears to work in all cases on
+                # OSX). Users are still free to override LANG of course, as
+                # long as it give us something meaningful. This work-around
+                # *may* not be needed with python 3k and/or OSX 10.5, but will
+                # work with them too -- vila 20080908
+                os.environ['LANG'] = 'en_US.UTF-8'
             import locale
         finally:
             sys.platform = 'darwin'



More information about the bazaar-commits mailing list