[PATCH 1 of 8] py3: don't use os.getcwdb() on Windows to avoid DeprecationWarnings
Yuya Nishihara
yuya at tcha.org
Sun Sep 23 06:37:37 UTC 2018
On Sat, 22 Sep 2018 11:28:37 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1537573703 14400
> # Fri Sep 21 19:48:23 2018 -0400
> # Node ID 758cf8cdf994942174238c28c8f06ece63dae2b5
> # Parent 7e99b02768ef396b5c4b7a9126c329f49af3e2bf
> py3: don't use os.getcwdb() on Windows to avoid DeprecationWarnings
>
> See also ac32685011a3.
>
> diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
> --- a/mercurial/pycompat.py
> +++ b/mercurial/pycompat.py
> @@ -100,6 +100,13 @@ if ispy3:
> # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
> # returns bytes.
> getcwd = os.getcwdb
> +
> + # Python 3 on Windows issues a DeprecationWarning about using the bytes API
> + # when os.getcwdb() is called.
> + if osname == 'nt':
> + from . import encoding # encoding imports pycompat
> + getcwd = lambda: encoding.strtolocal(os.getcwd())
Can you move this to encoding.getcwd() just like encoding.environ?
More information about the Mercurial-devel
mailing list