[PATCH 3 of 7] py3: make scmpoxis.systemrcpath() return bytes
Yuya Nishihara
yuya at tcha.org
Thu Nov 3 23:40:17 EDT 2016
On Thu, 03 Nov 2016 03:53:08 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit at gmail.com>
> # Date 1478119178 -19800
> # Thu Nov 03 02:09:38 2016 +0530
> # Node ID 9d54c24d17daddf2ede7fe7ce58751ab9a1780a4
> # Parent 6585e9c1d915818d5138f6cb4134707002d5d749
> py3: make scmpoxis.systemrcpath() return bytes
>
> The variable `p` is a str on Python 3 which is not bytes. We should convert
> it to bytes because
> 1. root is bytes and we want the final output in bytes
> 2. to make the if condition works fine because in py3 its p != b'/'
>
> So even if p is '/' but left as a str on py3, will make the condition false.
> This patch ensures that scmposix.systemrcpath() return bytes and also
> scmposix._rcfiles() returns and accepts bytes. The later is used in
> scmposix.py only.
>
> diff -r 6585e9c1d915 -r 9d54c24d17da mercurial/scmposix.py
> --- a/mercurial/scmposix.py Thu Nov 03 01:55:44 2016 +0530
> +++ b/mercurial/scmposix.py Thu Nov 03 02:09:38 2016 +0530
> @@ -27,6 +27,8 @@
> # old mod_python does not set sys.argv
> if len(getattr(sys, 'argv', [])) > 0:
> p = os.path.dirname(os.path.dirname(sys.argv[0]))
> + if not isinstance(p, bytes):
> + p = p.encode('utf-8')
We can't assume external encoding is UTF-8. IIRC, Augie had some patches
to work around the sys.argv issue.
More information about the Mercurial-devel
mailing list