[PATCH 06 of 10] py3: convert url to str before passing in urllib.request.Request
Yuya Nishihara
yuya at tcha.org
Tue May 9 10:38:39 EDT 2017
On Sat, 06 May 2017 08:31:18 +0530, Pulkit Goyal wrote:
> # 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))
Perhaps here self._url must be an ASCII string and that's important. How
about adding a function that converts bytes url back to str?
More information about the Mercurial-devel
mailing list