def _url_escape(s): ### quote_plus barfs on non-ASCII characters. According to ### http://www.w3.org/International/O-URL-code.html URIs should be ### UTF-8 encoded first. if isinstance(s, unicode): s = s.encode('utf8') return urllib_parse_quote_plus(s)