[PATCH] default _fs_enc to 'ascii' when sys.getfilesystemencoding() is nil.
Martin Pool
mbp at canonical.com
Tue Oct 10 01:49:26 BST 2006
On 9 Oct 2006, Bart Teeuwisse <bart-gmane at thecodemill.biz> wrote:
> Title and comments below say it all.
Thanks. We should assume something if Python returns None, but it could
plausibly be either ascii or utf-8.
Bart, as another data point, what encoding are file names on your
system?
If the person only uses ascii characters it makes no difference.
If they use utf-8 then that will work and ascii will fail.
If they use a non-utf-8 national encoding for file names then either
ascii or utf-8 will fail. (I think it's very rare for a string in some
other encoding to coincidentally be valid utf-8.) Non utf-8 filenames
do happen on some systems but it seems less common. So I would say, use
utf-8.
> === modified file 'bzrlib/osutils.py'
> --- bzrlib/osutils.py 2006-09-15 00:44:57 +0000
> +++ bzrlib/osutils.py 2006-10-09 17:08:21 +0000
> @@ -221,7 +221,11 @@
> # choke on a Unicode string containing a relative path if
> # os.getcwd() returns a non-sys.getdefaultencoding()-encoded
> # string.
> -_fs_enc = sys.getfilesystemencoding()
> +
> +# Default to 'ascii' on systems that don't return file system
> +# encoding. Python 2.4.3 on FreeBSD 4.11 is a known
> +# example. _posix_realpath breaks if _fs_enc is empty.
> +_fs_enc = sys.getfilesystemencoding() or 'ascii'
> def _posix_abspath(path):
> # jam 20060426 rather than encoding to fsencoding
> # copy posixpath.abspath, but use os.getcwdu instead
>
>
--
Martin
More information about the bazaar
mailing list