Merge lp:~gz/bzr/no_locale_hacks_570495 into lp:bzr
Status: | Merged |
---|---|
Approved by: | Jelmer Vernooij |
Approved revision: | no longer in the source branch. |
Merged at revision: | 6427 |
Proposed branch: | lp:~gz/bzr/no_locale_hacks_570495 |
Merge into: | lp:bzr |
Diff against target: |
314 lines (+55/-144) 4 files modified
bzr (+2/-19) bzrlib/osutils.py (+32/-73) bzrlib/tests/test_osutils_encodings.py (+15/-52) doc/en/release-notes/bzr-2.5.txt (+6/-0) |
To merge this branch: | bzr merge lp:~gz/bzr/no_locale_hacks_570495 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jelmer Vernooij (community) | Approve | ||
Review via email: mp+86236@code.launchpad.net |
Commit message
Simplify osutils.
Description of the change
Remove the need to hack around a Python bug on OSX and don't call setlocale from get_user_encoding to determine the character set. These are some quite large changes to a pretty central bzrlib function, and there may be fallout api users, but I'm keen to try and minimise that. It would be possible to extend the "treat ascii as utf-8" cludge to all posix systems, but if possible I'd like to avoid this and instead make the UI assume unicode output in fewer places, which is needed for other reasons regardless.
Not calling setlocale inside get_user_encoding is a good thing in the long run. Users of bzrlib that want localised output should be setting a valid locale at startup, rather than delaying till to an arbitrary later point and only affecting a setting that some parts of the program will use. We also need to sensibly handle output in cases where the base locale codeset is not UTF-8, which tends to get overlooked currently.
The deprecation of use_cache is mostly because this is a public function that will be around for a long time, and the implementation shouldn't be bound by an interface designed just for testability.
To enumerate the visible effects of these changes:
* The value returned will be normalised to the python codec name.
* Remove the fiddling with sys.platform which may help pypy a little.
OSX
===
* UTF-8 will still be used if LANG is unset, but LANG won't be touched.
* If LANG is C or another valid value that results in ascii, UTF-8 will be used,
Other posix
===========
* If setlocale is not already called (as it is in the bzr script), "ascii" will be used.