~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: John Arbash Meinel
  • Date: 2011-01-12 17:50:16 UTC
  • mto: This revision was merged to the branch mainline in revision 5601.
  • Revision ID: john@arbash-meinel.com-20110112175016-5jtrkw4dubty2jjj
Decode windows env vars using mbcs rather than assuming the 8-bit string is ok.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#            and others
4
4
#
1131
1131
    """
1132
1132
    base = os.environ.get('BZR_HOME', None)
1133
1133
    if sys.platform == 'win32':
 
1134
        if base is not None:
 
1135
            # environ variables on Windows are in user encoding/mbcs, we should
 
1136
            # decode it to a Unicode variable
 
1137
            base = base.decode('mbcs')
1134
1138
        if base is None:
1135
1139
            base = win32utils.get_appdata_location_unicode()
1136
1140
        if base is None:
1137
1141
            base = os.environ.get('HOME', None)
 
1142
            if base is not None:
 
1143
                base = base.decode('mbcs')
1138
1144
        if base is None:
1139
1145
            raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
1140
1146
                                  ' or HOME set')