mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-31 00:24:13 +00:00
fuse/blackmatch: update json handling to support simplejson v2
simplejson v2 returns strings as either unicode or str, depending upon its mood. thus the interpretation of the node's json repr of a directory, and the serialisation of strings in the json based rpc both exploded when built against simplejson v2. this makes both of these places liberal in their acceptance of either str or unicode.
This commit is contained in:
parent
7ee6882884
commit
e679d48660
@ -105,9 +105,12 @@ def log(msg):
|
||||
|
||||
fuse.flog = log
|
||||
|
||||
def unicode_to_utf8(u):
|
||||
precondition(isinstance(u, unicode), repr(u))
|
||||
return u.encode('utf-8')
|
||||
def unicode_to_utf8_or_str(u):
|
||||
if isinstance(u, unicode):
|
||||
return u.encode('utf-8')
|
||||
else:
|
||||
precondition(isinstance(u, str), repr(u))
|
||||
return u
|
||||
|
||||
def do_http(method, url, body=''):
|
||||
resp = do_http_req(method, url, body)
|
||||
@ -834,7 +837,7 @@ class Directory(object):
|
||||
assert nodetype == 'dirnode'
|
||||
self.children.clear()
|
||||
for cname,details in d['children'].items():
|
||||
cname = unicode_to_utf8(cname)
|
||||
cname = unicode_to_utf8_or_str(cname)
|
||||
ctype, cattrs = details
|
||||
metadata = cattrs.get('metadata', {})
|
||||
if ctype == 'dirnode':
|
||||
@ -1142,7 +1145,7 @@ def print_tree():
|
||||
def unmarshal(obj):
|
||||
if obj is None or isinstance(obj, int) or isinstance(obj, long) or isinstance(obj, float):
|
||||
return obj
|
||||
elif isinstance(obj, unicode):
|
||||
elif isinstance(obj, unicode) or isinstance(obj, str):
|
||||
#log('unmarshal(%r)' % (obj,))
|
||||
return base64.b64decode(obj)
|
||||
elif isinstance(obj, list):
|
||||
|
Loading…
x
Reference in New Issue
Block a user