[MERGE] fixes for TestCase.run_bzr* methods

John Arbash Meinel john at arbash-meinel.com
Thu Sep 27 18:22:49 BST 2007


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

Alexander Belchenko wrote:
...


> run bzr: ['p\x00u\x00s\x00h\x00', '\x00-\x00d\x00',
> '\x00f\x00i\x00l\x00e\x00:\x00/\x00/\x00/\x00C\x00:\x00/\x00d\x00o\x00c\x00u\x00m\x00e\x00%\x007\x00E\x001\x00/\x00m\x00o\x00d\x00u\x00l\x00/\x00l\x00o\x00c\x00a\x00l\x00s\x00%\x007\x00E\x001\x00/\x00t\x00e\x00m\x00p\x00/\x00t\x00e\x00s\x00t\x00b\x00z\x00r\x00-\x00t\x00a\x005\x00e\x00x\x00i\x00.\x00t\x00m\x00p\x00/\x00t\x00m\x00p\x00x\x00-\x00n\x00y\x00k\x00d\x00/\x00w\x00o\x00r\x00k\x00/\x00f\x00r\x00o\x00m\x00',
> '\x00f\x00i\x00l\x00e\x00:\x00/\x00/\x00/\x00C\x00:\x00/\x00d\x00o\x00c\x00u\x00m\x00e\x00%\x007\x00E\x001\x00/\x00m\x00o\x00d\x00u\x00l\x00/\x00l\x00o\x00c\x00a\x00l\x00s\x00%\x007\x00E\x001\x00/\x00t\x00e\x00m\x00p\x00/\x00t\x00e\x00s\x00t\x00b\x00z\x00r\x00-\x00t\x00a\x005\x00e\x00x\x00i\x00.\x00t\x00m\x00p\x00/\x00t\x00m\x00p\x00x\x00-\x00n\x00y\x00k\x00d\x00/\x00w\x00o\x00r\x00k\x00/\x00t\x00o\x00-\x00t\x00w\x00o\x00']
> bzr arguments: ['p\x00u\x00s\x00h\x00', '\x00-\x00d\x00',
> '\x00f\x00i\x00l\x00e\x00:\x00/\x00/\x00/\x00C\x00:\x00/\x00d\x00o\x00c\x00u\x00m\x00e\x00%\x007\x00E\x001\x00/\x00m\x00o\x00d\x00u\x00l\x00/\x00l\x00o\x00c\x00a\x00l\x00s\x00%\x007\x00E\x001\x00/\x00t\x00e\x00m\x00p\x00/\x00t\x00e\x00s\x00t\x00b\x00z\x00r\x00-\x00t\x00a\x005\x00e\x00x\x00i\x00.\x00t\x00m\x00p\x00/\x00t\x00m\x00p\x00x\x00-\x00n\x00y\x00k\x00d\x00/\x00w\x00o\x00r\x00k\x00/\x00f\x00r\x00o\x00m\x00',
> '\x00f\x00i\x00l\x00e\x00:\x00/\x00/\x00/\x00C\x00:\x00/\x00d\x00o\x00c\x00u\x00m\x00e\x00%\x007\x00E\x001\x00/\x00m\x00o\x00d\x00u\x00l\x00/\x00l\x00o\x00c\x00a\x00l\x00s\x00%\x007\x00E\x001\x00/\x00t\x00e\x00m\x00p\x00/\x00t\x00e\x00s\x00t\x00b\x00z\x00r\x00-\x00t\x00a\x005\x00e\x00x\x00i\x00.\x00t\x00m\x00p\x00/\x00t\x00m\x00p\x00x\x00-\x00n\x00y\x00k\x00d\x00/\x00w\x00o\x00r\x00k\x00/\x00t\x00o\x00-\x00t\x00w\x00o\x00']
> Traceback (most recent call last):
>   File "C:\work\Bazaar\bzr.dev\bzrlib\commands.py", line 801, in run_bzr_catch_errors
>     return run_bzr(argv)
>   File "C:\work\Bazaar\bzr.dev\bzrlib\commands.py", line 749, in run_bzr
>     cmd_obj = get_cmd_object(cmd, plugins_override=not opt_builtin)
>   File "C:\work\Bazaar\bzr.dev\bzrlib\commands.py", line 144, in get_cmd_object
>     raise errors.BzrCommandError('unknown command "%s"' % cmd_name)
> BzrCommandError: unknown command "p u s h "

Well, this looks like it is treating the Unicode object as a string object,
without actually converting it.

Specifically: 'p\x00u\x00s\x00\h\x00' is UTF-16LE for 'push'. (I'm pretty sure
Win32 python uses UTF-16/UCS2 internally, and not UTF-32/UCS4.)

I'm guessing this is because shlex is going through a cStringIO, which is known
for doing very broken things with Unicode arguments.

The reason to go through an encode/decode pair, is so that we can still do:

self.run_bzr(u'command "\xb5nicode argument"')

At the moment, I would guess that we never do that, and it would be okay to
require those tests to switch to:

self.run_bzr(['command', u'\xb5nicode argument'])

so the 'str(arg)' form is ok, just not quite as complete as encode/decode. And
since it is only in the test suite, I'm not as concerned about performance. (It
is a pain to have the test suite take forever, though, so I'm a little
concerned about it.)

But if it was a big deal, then all of them should be switched to the
run_bzr(['arg']) form, since that has less processing to do that shlex.split().

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

iD8DBQFG++bpJdeBCYSNAAMRAmLjAJ9ccNxHRAB8eAJlPOvra95OuSy84ACgz4Tk
5eXKJ6Q8KCntIQ3JlCj+UXY=
=WRoP
-----END PGP SIGNATURE-----



More information about the bazaar mailing list