def escape_rfc3986(s):
 if ((sys.version_info < (3, 0)) and isinstance(s, compat_str)):
  s = s.encode(u'utf-8')
 return compat_urllib_parse.quote(s, "%/;:@&=+$,!~*'()?#[]")

def escape_rfc3986 ( s ) : if ( ( sys . version_info < ( 3 , 0 ) ) and isinstance ( s , compat_str ) ) : s = s . encode ( u'utf-8' ) return compat_urllib_parse . quote ( s , "%/;:@&=+$,!~*'()?#[]" )
escape non-ascii characters as suggested by rfc 3986 .