[MERGE] Running bzr from vim scripts gives 'unknown encoding warning'

John Arbash Meinel john at arbash-meinel.com
Wed May 21 14:40:42 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Martin Pool wrote:
| On Tue, May 6, 2008 at 12:45 PM, Neil Martinsen-Burrell
| <nmb at wartburg.edu> wrote:
|> I can't figure out the difference between "python -c "import locale; print
|> locale.getpreferredencoding" and the corresponding line in osutils.py,
|> particularly in a way that only appears under gvim.
|
| Maybe it is due to this preceding code in get_user_encoding, which has
| a somewhat obscure comment:
|
|     if sys.platform == 'darwin':
|         # work around egregious python 2.4 bug
|         sys.platform = 'posix'
|         try:
|             import locale
|         finally:
|             sys.platform = 'darwin'
|     else:
|         import locale
|
| John explains on 2006-2-20 as:
|
| ## Which basically forces python to honor the LANG setting, ## even on
| Mac. On other platforms, it does the right thing. ## On Mac it is
| (incorrectly?)
| ## hardcoded to Mac-Roman because of legacy issues.
|
| If this has been fixed after 2.5 which the comment seems to imply then
| maybe we should check the Python version too?

I don't know. I have since moved away from the Mac platform, so I can't test it
with python2.5. I certainly remember that bug, as I used Mac with their standard
UTF-8 console and it always wanted to print stuff as Mac-Roman.

I do see this code in 'locale.py'
if sys.platform in ('win32', 'darwin', 'mac'):
~    # On Win32, this will return the ANSI code page
~    # On the Mac, it should return the system encoding;
~    # it might return "ascii" instead
~    def getpreferredencoding(do_setlocale = True):
~        """Return the charset that the user is likely using."""
~        import _locale
~        return _locale._getdefaultlocale()[1]


Which is the same between python 2.4 and python 2.5

It might be that I should be setting the "system locale" somewhere else on the
system, rather than setting LANG=en_US.UTF-8 in .bashrc. Switching to 'posix'
and setting LANG worked for me.

|
| On the whole I agree with Ian that it would be an advance to put it
| in; I'll merge it and also add something to news.
|

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkg0JloACgkQJdeBCYSNAAMsxgCfTyFrrz6c83OnYkKiud5WY8lk
TeMAn2escDV18a0gPZw6UTBdrcnT0K6c
=BC7R
-----END PGP SIGNATURE-----



More information about the bazaar mailing list