Rev 5599: Decode windows env vars using mbcs rather than assuming the 8-bit string is ok. in http://bazaar.launchpad.net/~jameinel/bzr/2.3-unicode-home

John Arbash Meinel john at arbash-meinel.com
Wed Jan 12 17:50:22 UTC 2011


At http://bazaar.launchpad.net/~jameinel/bzr/2.3-unicode-home

------------------------------------------------------------
revno: 5599
revision-id: john at arbash-meinel.com-20110112175016-5jtrkw4dubty2jjj
parent: pqm at pqm.ubuntu.com-20110112013446-le2folid2nfkgncn
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.3-unicode-home
timestamp: Wed 2011-01-12 11:50:16 -0600
message:
  Decode windows env vars using mbcs rather than assuming the 8-bit string is ok.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2010-11-29 01:23:53 +0000
+++ b/bzrlib/config.py	2011-01-12 17:50:16 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2010 Canonical Ltd
+# Copyright (C) 2005-2011 Canonical Ltd
 #   Authors: Robert Collins <robert.collins at canonical.com>
 #            and others
 #
@@ -1131,10 +1131,16 @@
     """
     base = os.environ.get('BZR_HOME', None)
     if sys.platform == 'win32':
+        if base is not None:
+            # environ variables on Windows are in user encoding/mbcs, we should
+            # decode it to a Unicode variable
+            base = base.decode('mbcs')
         if base is None:
             base = win32utils.get_appdata_location_unicode()
         if base is None:
             base = os.environ.get('HOME', None)
+            if base is not None:
+                base = base.decode('mbcs')
         if base is None:
             raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
                                   ' or HOME set')



More information about the bazaar-commits mailing list