[PATCH 1 of 8] py3: don't use os.getcwdb() on Windows to avoid DeprecationWarnings
Matt Harbison
mharbison72 at gmail.com
Sat Sep 22 15:28:37 UTC 2018
# 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())
+
sysplatform = sys.platform.encode('ascii')
sysexecutable = sys.executable
if sysexecutable:
More information about the Mercurial-devel
mailing list