[RFC] shlex.split is bad for win32
Maritza Mendez
martitzam at gmail.com
Thu Jun 25 19:01:03 BST 2009
On Thu, Jun 25, 2009 at 2:33 AM, Alexander Belchenko <bialix at ukr.net> wrote:
> In [1]: import shlex
>
> In [2]: shlex.split(r'foo C:/bar/spam')
> Out[2]: ['foo', 'C:/bar/spam']
>
> In [3]: shlex.split(r'foo C:\bar\spam')
> Out[3]: ['foo', 'C:barspam']
>
> This affects some plugins, but more important: it affects `bzr diff --using
> xxx`
>
> E.g. bzr diff --using "C:\Program Files\WinMerge\WinMergeU.exe" does not
> work, while bzr diff --using "C:/Program Files/WinMerge/WinMergeU.exe" does
> actually work.
>
Yes. Some parts of bzr are more Win-friendly than others. This drove me
crazy at first. Eventually I ended up escaping just about everything.
> Instead of shlex.split should be used Win32 API CommandLineToArgvW()
> function (http://msdn.microsoft.com/en-us/library/bb776391(VS.85).aspx<http://msdn.microsoft.com/en-us/library/bb776391%28VS.85%29.aspx>
> )
> This function is already using in win32utils:get_unicode_argv() function.
>
> There is special function in commands.py
>
> def shlex_split_unicode(unsplit):
> import shlex
> return [u.decode('utf-8') for u in shlex.split(unsplit.encode('utf-8'))]
>
>
> So I think it should be platform dependent and use right method on win32.
> Right?
>
> Dear plugin writers! Please use the function shlex_split_unicode in your
> plugins and never shlex.split directly. So once someone will fix its
> behavior re backslashes your plugin will work much better on Windows.
> Thanks.
It would be helpful to also add this advice to the Portability Tips in
HACKING.txt.
-M
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/bazaar/attachments/20090625/47a141f4/attachment.htm
More information about the bazaar
mailing list