changeset 39824:fb628c048d64

py3: don't use os.getcwdb() on Windows to avoid DeprecationWarnings See also ac32685011a3.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 23 Sep 2018 22:36:44 -0400
parents 24e493ec2229
children 68ea1f8dcb84
files mercurial/encoding.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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