def squash_unicode(obj):
if isinstance(obj,dict):<EOL><INDENT>for key in obj.keys():<EOL><INDENT>obj[key] = squash_unicode(obj[key])<EOL>if isinstance(key, unicode):<EOL><INDENT>obj[squash_unicode(key)] = obj.pop(key)<EOL><DEDENT><DEDENT><DEDENT>elif isinstance(obj, list):<EOL><INDENT>for i,v in enumerate(obj):<EOL><INDENT>obj[i] = squash_unicode(v)<EOL><DEDENT><DEDENT>elif isinstance(obj, unicode):<EOL><INDENT>obj = obj.encode('<STR_LIT:utf8>')<EOL><DEDENT>return obj<EOL>
coerce unicode back to bytestrings.