[PATCH 06 of 10] py3: convert url to str before passing in urllib.request.Request

Pulkit Goyal 7895pulkit at gmail.com
Fri May 5 23:01:18 EDT 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1494029803 -19800
#      Sat May 06 05:46:43 2017 +0530
# Node ID 6065574d18279e75caa5b1172e4149fc498eccd9
# Parent  1a38d712f305b2dd5f2b2833cd78815ec3b383fd
py3: convert url to str before passing in urllib.request.Request

If we try to instantiate urllib.request.Request with a bytes url, it returns
ValueError from urllib.request.Request._parse().

Related link: https://hg.python.org/cpython/file/3.5/Lib/urllib/request.py#l321

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -175,7 +175,7 @@
             else:
                 q += sorted(args.items())
         qs = '?%s' % urlreq.urlencode(q)
-        cu = "%s%s" % (self._url, qs)
+        cu = pycompat.sysstr("%s%s" % (self._url, qs))
         size = 0
         if util.safehasattr(data, 'length'):
             size = data.length


More information about the Mercurial-devel mailing list