py3: don't use os.getcwdb() on Windows to avoid DeprecationWarnings
authorMatt Harbison <matt_harbison@yahoo.com>
Sun, 23 Sep 2018 22:36:44 -0400
changeset 39819 fb628c048d64
parent 39818 24e493ec2229
child 39820 68ea1f8dcb84
py3: don't use os.getcwdb() on Windows to avoid DeprecationWarnings See also ac32685011a3.
mercurial/encoding.py
--- a/mercurial/encoding.py	Fri Sep 21 19:48:23 2018 -0400
+++ b/mercurial/encoding.py	Sun Sep 23 22:36:44 2018 -0400
@@ -236,7 +236,12 @@
 if pycompat.ispy3:
     # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
     # returns bytes.
-    getcwd = os.getcwdb  # re-exports
+    if pycompat.iswindows:
+        # Python 3 on Windows issues a DeprecationWarning about using the bytes
+        # API when os.getcwdb() is called.
+        getcwd = lambda: strtolocal(os.getcwd())  # re-exports
+    else:
+        getcwd = os.getcwdb  # re-exports
 else:
     getcwd = os.getcwd  # re-exports