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
1=== modified file 'bzrlib/config.py'
2--- bzrlib/config.py 2010-11-29 01:23:53 +0000
3+++ bzrlib/config.py 2011-01-12 18:16:32 +0000
4@@ -1,4 +1,4 @@
5-# Copyright (C) 2005-2010 Canonical Ltd
6+# Copyright (C) 2005-2011 Canonical Ltd
7 # Authors: Robert Collins <robert.collins@canonical.com>
8 # and others
9 #
10@@ -1131,10 +1131,16 @@
11 """
12 base = os.environ.get('BZR_HOME', None)
13 if sys.platform == 'win32':
14+ # environ variables on Windows are in user encoding/mbcs. So decode
15+ # before using one
16+ if base is not None:
17+ base = base.decode('mbcs')
18 if base is None:
19 base = win32utils.get_appdata_location_unicode()
20 if base is None:
21 base = os.environ.get('HOME', None)
22+ if base is not None:
23+ base = base.decode('mbcs')
24 if base is None:
25 raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
26 ' or HOME set')