Merge lp:~jameinel/bzr/2.3-unicode-home into lp:bzr

Proposed by John A Meinel
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5601
Proposed branch: lp:~jameinel/bzr/2.3-unicode-home
Merge into: lp:bzr
Diff against target: 26 lines (+7/-1)
1 file modified
bzrlib/config.py (+7/-1)
To merge this branch: bzr merge lp:~jameinel/bzr/2.3-unicode-home
Reviewer Review Type Date Requested Status
Martin Packman (community) Approve
Vincent Ladeuil Needs Fixing
Review via email: mp+46015@code.launchpad.net

Commit message

Decode config_dir() environment variables on Windows using 'mbcs'

Description of the change

This changes config_dir() to handle non-ascii environment variables. 'mbcs' seems the sanest way to do it on Windows. It gets the bzrlib.tests.blackbox.test_version...test_unicode_bzr_home to pass on Windows.

This is the most sane small change that I can come up with, and I'm pretty ok with it.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

Put the same comment above both .decode() and land !

review: Needs Fixing
Revision history for this message
Martin Packman (gz) wrote :

This is basically the right thing and covers every reasonable use of bzr without having to resort to recreating chunks of Python 3. None of the 'mbcs' codec pitfalls apply here as the value we're reading has already been mangled to fit in the locale encoding.

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/config.py'
--- bzrlib/config.py 2010-11-29 01:23:53 +0000
+++ bzrlib/config.py 2011-01-12 18:16:32 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005-2010 Canonical Ltd1# Copyright (C) 2005-2011 Canonical Ltd
2# Authors: Robert Collins <robert.collins@canonical.com>2# Authors: Robert Collins <robert.collins@canonical.com>
3# and others3# and others
4#4#
@@ -1131,10 +1131,16 @@
1131 """1131 """
1132 base = os.environ.get('BZR_HOME', None)1132 base = os.environ.get('BZR_HOME', None)
1133 if sys.platform == 'win32':1133 if sys.platform == 'win32':
1134 # environ variables on Windows are in user encoding/mbcs. So decode
1135 # before using one
1136 if base is not None:
1137 base = base.decode('mbcs')
1134 if base is None:1138 if base is None:
1135 base = win32utils.get_appdata_location_unicode()1139 base = win32utils.get_appdata_location_unicode()
1136 if base is None:1140 if base is None:
1137 base = os.environ.get('HOME', None)1141 base = os.environ.get('HOME', None)
1142 if base is not None:
1143 base = base.decode('mbcs')
1138 if base is None:1144 if base is None:
1139 raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'1145 raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
1140 ' or HOME set')1146 ' or HOME set')