From: Zooko O'Whielacronx Date: Tue, 23 Dec 2008 00:54:53 +0000 (-0700) Subject: cli: decode all cli arguments, assuming that they are utf-8 encoded X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/...?a=commitdiff_plain;h=36df38e58b4042bc38af7d4df69c73ff83ce2f4a;p=tahoe-lafs%2Ftahoe-lafs.git 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. --- diff --git a/src/allmydata/scripts/common.py b/src/allmydata/scripts/common.py index a6d0a109..fb404ce1 100644 --- a/src/allmydata/scripts/common.py +++ b/src/allmydata/scripts/common.py @@ -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]) diff --git a/src/allmydata/scripts/runner.py b/src/allmydata/scripts/runner.py index 235cc2a0..45a2c65b 100644 --- a/src/allmydata/scripts/runner.py +++ b/src/allmydata/scripts/runner.py @@ -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)