def quote(value, safe='<STR_LIT>'):
if isinstance(value, six.text_type):<EOL><INDENT>value = value.encode('<STR_LIT:utf8>')<EOL><DEDENT>elif not isinstance(value, six.string_types):<EOL><INDENT>value = str(value)<EOL><DEDENT>return parse.quote(value, safe)<EOL>
Much like parse.quote in that it returns a URL encoded string
for the given value, protecting the safe characters; but this
version also ensures the value is UTF-8 encoded.