]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
URIs are strs.
authorDaira Hopwood <daira@jacaranda.org>
Tue, 20 Oct 2015 16:16:32 +0000 (17:16 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Mon, 28 Dec 2015 16:18:52 +0000 (16:18 +0000)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/scripts/magic_folder_cli.py
src/allmydata/uri.py

index 8227addaff15d8d4af057d86f511b309d3af2560..ef0d76f69af5fd5c2c53d95422347b8f67967099 100644 (file)
@@ -109,24 +109,28 @@ def invite(options):
     if rc != 0:
         print >>options.stderr, "magic-folder: failed to mkdir\n"
         return rc
+
+    # FIXME this assumes caps are ASCII.
     dmd_write_cap = mkdir_options.stdout.getvalue().strip()
-    dmd_readonly_cap = unicode(uri.from_string(dmd_write_cap).get_readonly().to_string(), 'utf-8')
+    dmd_readonly_cap = uri.from_string(dmd_write_cap).get_readonly().to_string()
     if dmd_readonly_cap is None:
         print >>options.stderr, "magic-folder: failed to diminish dmd write cap\n"
         return 1
 
     magic_write_cap = get_aliases(options["node-directory"])[options.alias]
-    magic_readonly_cap = unicode(uri.from_string(magic_write_cap).get_readonly().to_string(), 'utf-8')
+    magic_readonly_cap = uri.from_string(magic_write_cap).get_readonly().to_string()
+
     # tahoe ln CLIENT_READCAP COLLECTIVE_WRITECAP/NICKNAME
     ln_options = _delegate_options(options, LnOptions())
-    ln_options.from_file = dmd_readonly_cap
-    ln_options.to_file = u"%s/%s" % (magic_write_cap, options.nickname)
+    ln_options.from_file = unicode(dmd_readonly_cap, 'utf-8')
+    ln_options.to_file = u"%s/%s" % (unicode(magic_write_cap, 'utf-8'), options.nickname)
     rc = tahoe_mv.mv(ln_options, mode="link")
     if rc != 0:
         print >>options.stderr, "magic-folder: failed to create link\n"
         print >>options.stderr, ln_options.stderr.getvalue()
         return rc
 
+    # FIXME: this assumes caps are ASCII.
     print >>options.stdout, "%s%s%s" % (magic_readonly_cap, INVITE_SEPARATOR, dmd_write_cap)
     return 0
 
index 372e0b8be2605eb49c755b7a6aa45b588be1901f..4d6db482984fe5acec212b338ecc81727454cb29 100644 (file)
@@ -730,7 +730,7 @@ ALLEGED_IMMUTABLE_PREFIX = 'imm.'
 
 def from_string(u, deep_immutable=False, name=u"<unknown name>"):
     if not isinstance(u, str):
-        raise TypeError("unknown URI type: %s.." % str(u)[:100])
+        raise TypeError("URI must be str: %r" % (u,))
 
     # We allow and check ALLEGED_READONLY_PREFIX or ALLEGED_IMMUTABLE_PREFIX
     # on all URIs, even though we would only strictly need to do so for caps of