From: robk-tahoe Date: Fri, 7 Mar 2008 00:43:25 +0000 (-0700) Subject: macfuse: fix unicode handling X-Git-Tag: allmydata-tahoe-0.9.0~56 X-Git-Url: https://git.rkrishnan.org/pf/components/com_hotproperty/css/?a=commitdiff_plain;h=4bbaaff49fd75475ab23530e1401b39894318b6a;p=tahoe-lafs%2Ftahoe-lafs.git macfuse: fix unicode handling at one point I'd thrown in a 'str' since fuse api bits required a str instance but tahoe returns unicode objects from its json parsing. that, naturally enough should really be a utf8 encoded str of the unicode object... --- diff --git a/mac/tahoefuse.py b/mac/tahoefuse.py index 94fbff5c..fe97577c 100644 --- a/mac/tahoefuse.py +++ b/mac/tahoefuse.py @@ -4,6 +4,7 @@ from allmydata.uri import CHKFileURI, NewDirectoryURI, LiteralFileURI from allmydata.scripts.common_http import do_http as do_http_req from allmydata.util.hashutil import tagged_hash +from allmydata.util.assertutil import precondition from allmydata.util import base32 import base64 @@ -46,6 +47,10 @@ def log(msg): fuse.flog = log +def unicode_to_utf8(u): + precondition(isinstance(u, unicode), repr(u)) + return u.encode('utf-8') + def do_http(method, url, body=''): resp = do_http_req(method, url, body) log('do_http(%s, %s) -> %s, %s' % (method, url, resp.status, resp.reason)) @@ -487,7 +492,7 @@ class Directory(object): assert nodetype == 'dirnode' self.children.clear() for cname,details in d['children'].items(): - cname = str(cname) + cname = unicode_to_utf8(cname) ctype, cattrs = details metadata = cattrs.get('metadata', {}) if ctype == 'dirnode':