From 4bbaaff49fd75475ab23530e1401b39894318b6a Mon Sep 17 00:00:00 2001 From: robk-tahoe Date: Thu, 6 Mar 2008 17:43:25 -0700 Subject: [PATCH] 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... --- mac/tahoefuse.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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': -- 2.45.2