cli: decode all cli arguments, assuming that they are utf-8 encoded

Also encode all args to urllib as utf-8 because urllib doesn't handle unicode objects.
I'm not sure if it is appropriate to *assume* utf-8 encoding of cli args.  Perhaps the Right thing to do is to detect the platform encoding.  Any ideas?
This patch is mostly due to François Deppierraz.
This commit is contained in:
Zooko O'Whielacronx 2008-12-22 17:54:53 -07:00
parent ce5effbedf
commit 36df38e58b
2 changed files with 7 additions and 1 deletions

View File

@ -129,4 +129,4 @@ def get_alias(aliases, path, default):
def escape_path(path):
segments = path.split("/")
return "/".join([urllib.quote(s) for s in segments])
return "/".join([urllib.quote(s.encode('utf-8')) for s in segments])

View File

@ -33,6 +33,12 @@ def runner(argv,
stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr,
install_node_control=True, additional_commands=None):
# Convert arguments to unicode
new_argv = []
for arg in argv:
new_argv.append(arg.decode('utf-8'))
argv = new_argv
config = Options()
if install_node_control:
config.subCommands.extend(startstop_node.subCommands)