py3: add a bytes version of urllib.parse.urlencode() to pycompat.py
urllib.parse.urlencode() returns unicodes on Python 3. This commit adds a
method which will take its output and encode it to bytes so that we can use
bytes consistently.
--- a/mercurial/pycompat.py Fri Apr 07 13:46:35 2017 +0530
+++ b/mercurial/pycompat.py Fri Apr 07 16:00:44 2017 +0530
@@ -399,4 +399,11 @@
s = urllib.parse.quote_from_bytes(s, safe=safe)
return s.encode('ascii', 'strict')
+ # urllib.parse.urlencode() returns str. We use this function to make
+ # sure we return bytes.
+ def urlencode(query, doseq=False):
+ s = urllib.parse.urlencode(query, doseq=doseq)
+ return s.encode('ascii')
+
urlreq.quote = quote
+ urlreq.urlencode = urlencode