[MERGE] Running bzr from vim scripts gives 'unknown encoding warning'
nmb at wartburg.edu
Tue May 6 03:45:21 BST 2008
Martin Pool wrote:
> My impression is that he is not setting it but rather inheriting the
> setting from his environment. Presumably it is set correctly at at
> least the login level and there is a bug somewhere in the os, vim, the
> script, python, or bzr.
> Neil since you can reproduce this could you find out what bzr thinks
> the locale is? (by e.g. printing locale.getlocale() in this message.)
> That might tell us more about where the problem is.
Here is what I see when executing the shell command "python -c "import
locale; print locale.getpreferredencoding(); print locale.getlocale()"
in various contexts:
In the terminal:
nmb at guttle[~]$ python -c "import locale;print \
locale.getpreferredencoding(); print locale.getlocale()"
In vim and gvim:
:! python -c "import locale;print locale.getpreferredencoding(); print
In vim using system() (this is how bzr is executed in the vcscommand
:let out=system("python -c \"import locale;print
locale.gereferredencoding(); print locale.getlocale()\"")
But, with this patch applied to bzrlib/osutils.py
=== modified file 'bzrlib/osutils.py'
--- bzrlib/osutils.py 2008-04-07 07:34:32 +0000
+++ bzrlib/osutils.py 2008-05-06 02:18:57 +0000
@@ -1353,9 +1353,9 @@
- ' unknown encoding %s.'
+ ' unknown encoding %s in locale %s.'
' Continuing with ascii encoding.\n'
- % user_encoding
+ % (user_encoding, locale.getlocale())
user_encoding = 'ascii'
I get the following from gvim (but not vim in the terminal!):
:let out=system("bzr info .")
bzr: warning: unknown encoding in locale (None, None). Continuing with
Repository tree (format: pack-0.92)
shared repository: /Users/nmb/src/bzr
repository branch: /Users/nmb/src/bzr/bzr.dev
parent branch: http://bazaar-vcs.org/bzr/bzr.dev/
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.
> So if we merge this, we might get a bug in future that non-ascii diffs
> don't work properly under vim on osx. Generally we don't want to
> sweep this bug under the covers. On the other hand it seems quite
> possibly a vim or vim script bug not ours. If we are asked to use the
> locale '' ascii may be the most reasonable interpretation.
It isn't clear to me from the above where the bug lies, but the original
patch in this thread fixes the appearance of the warning message for me.
If I can provide more information, please do ask.
More information about the bazaar