diff mercurial/pycompat.py @ 43091:127cc1f72e70

py3: stop normalizing .encode()/.decode() arguments to unicode Now that we don't byte transform string literals, we no longer need this transform. While we're here, we also drop some superfluous u'' prefix in existing callers. Differential Revision: https://phab.mercurial-scm.org/D7011
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 06 Oct 2019 17:27:51 -0400
parents 1f339b503a40
children 813aa8cc55d4
line wrap: on
line diff
--- a/mercurial/pycompat.py	Sun Oct 06 16:58:55 2019 -0400
+++ b/mercurial/pycompat.py	Sun Oct 06 17:27:51 2019 -0400
@@ -206,7 +206,7 @@
             ) and not hasattr(  # hasattr-py3-only
                 s, u'__bytes__'
             ):
-                s = str(s).encode(u'ascii')
+                s = str(s).encode('ascii')
             return bytes.__new__(cls, s)
 
         def __getitem__(self, key):
@@ -237,7 +237,7 @@
         This never raises UnicodeEncodeError, but only ASCII characters
         can be round-trip by sysstr(sysbytes(s)).
         """
-        return s.encode(u'utf-8')
+        return s.encode('utf-8')
 
     def sysstr(s):
         """Return a keyword str to be passed to Python functions such as
@@ -249,18 +249,18 @@
         """
         if isinstance(s, builtins.str):
             return s
-        return s.decode(u'latin-1')
+        return s.decode('latin-1')
 
     def strurl(url):
         """Converts a bytes url back to str"""
         if isinstance(url, bytes):
-            return url.decode(u'ascii')
+            return url.decode('ascii')
         return url
 
     def bytesurl(url):
         """Converts a str url to bytes by encoding in ascii"""
         if isinstance(url, str):
-            return url.encode(u'ascii')
+            return url.encode('ascii')
         return url
 
     def raisewithtb(exc, tb):