[PATCH 4 of 4] py3: convert os.readlink() path to native strings

Yuya Nishihara yuya at tcha.org
Thu Sep 27 07:07:58 EDT 2018


On Wed, 26 Sep 2018 23:12:56 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1537924572 14400
> #      Tue Sep 25 21:16:12 2018 -0400
> # Node ID d7aa84fbb3da463c68190aa746cbc6af40c6b8bc
> # Parent  549bc25529a2d8d1c67736110c90491cc1eafc76
> py3: convert os.readlink() path to native strings

Queued the first three, thanks.

> Windows insisted that it needs to be str.  I skipped the stuff that's obviously
> posix only, and left `tests/f` and `run-tests.py` alone for now.
> 
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -1841,7 +1841,7 @@ def makelock(info, pathname):
>  
>  def readlock(pathname):
>      try:
> -        return os.readlink(pathname)
> +        return os.readlink(pycompat.fsdecode(pathname))

This makes readlock() return a unicode string on Python 3 because the type
of the return value *depends on* the input argument. And we indeed want a
bytes string.


More information about the Mercurial-devel mailing list