From 36df38e58b4042bc38af7d4df69c73ff83ce2f4a Mon Sep 17 00:00:00 2001
From: Zooko O'Whielacronx <zooko@zooko.com>
Date: Mon, 22 Dec 2008 17:54:53 -0700
Subject: [PATCH] =?utf8?q?cli:=20decode=20all=20cli=20arguments,=20assumin?=
 =?utf8?q?g=20that=20they=20are=20utf-8=20encoded=20Also=20encode=20all=20?=
 =?utf8?q?args=20to=20urllib=20as=20utf-8=20because=20urllib=20doesn't=20h?=
 =?utf8?q?andle=20unicode=20objects.=20I'm=20not=20sure=20if=20it=20is=20a?=
 =?utf8?q?ppropriate=20to=20*assume*=20utf-8=20encoding=20of=20cli=20args.?=
 =?utf8?q?=20=20Perhaps=20the=20Right=20thing=20to=20do=20is=20to=20detect?=
 =?utf8?q?=20the=20platform=20encoding.=20=20Any=20ideas=3F=20This=20patch?=
 =?utf8?q?=20is=20mostly=20due=20to=20Fran=C3=A7ois=20Deppierraz.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

---
 src/allmydata/scripts/common.py | 2 +-
 src/allmydata/scripts/runner.py | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

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)
-- 
2.45.2