py3: make sure decode() first argument is str
authorPulkit Goyal <7895pulkit@gmail.com>
Thu, 12 Apr 2018 15:05:49 +0530
changeset 37622 bfdd20d22a86
parent 37621 5537d8f5e989
child 37623 eb687c28a915
py3: make sure decode() first argument is str Uses pycompat.sysstr() to make sure we uses bytes on Python 2 and unicodes on Python 3. Differential Revision: https://phab.mercurial-scm.org/D3279
hgext/convert/common.py
--- a/hgext/convert/common.py	Thu Apr 12 23:14:38 2018 -0700
+++ b/hgext/convert/common.py	Thu Apr 12 15:05:49 2018 +0530
@@ -217,12 +217,13 @@
         if isinstance(s, unicode):
             return s.encode("utf-8")
         try:
-            return s.decode(encoding).encode("utf-8")
+            return s.decode(pycompat.sysstr(encoding)).encode("utf-8")
         except UnicodeError:
             try:
                 return s.decode("latin-1").encode("utf-8")
             except UnicodeError:
-                return s.decode(encoding, "replace").encode("utf-8")
+                return s.decode(pycompat.sysstr(encoding),
+                                "replace").encode("utf-8")
 
     def getchangedfiles(self, rev, i):
         """Return the files changed by rev compared to parent[i].