diff hglib/util.py @ 142:fe74d5599539

hglib: wrap all application string literals in util.b() (issue4520) Conversion also included changing use of string interpolation to string concatenation as bytes interpolation does not exist in Python 3. Indexing related to bytes was also changed to length-1 bytes through slicing as Python 3 returns an int in this instance. Tests have not been switched to using util.b() so that the change to application code can be independently verified as not being broken.
author Brett Cannon <brett@python.org>
date Sun, 08 Mar 2015 13:08:37 -0400
parents ea80bd2775f6
children f3c430afa598
line wrap: on
line diff
--- a/hglib/util.py	Sat Mar 07 10:08:52 2015 -0500
+++ b/hglib/util.py	Sun Mar 08 13:08:37 2015 -0400
@@ -31,7 +31,7 @@
         n -= 1
         if n == 0:
             return cs.read()
-    return ''
+    return b('')
 
 def skiplines(s, prefix):
     """
@@ -52,7 +52,7 @@
         if not line.startswith(prefix):
             return line + cs.read()
 
-    return ''
+    return b('')
 
 def cmdbuilder(name, *args, **kwargs):
     """
@@ -88,12 +88,12 @@
         if val is None:
             continue
 
-        arg = arg.replace('_', '-')
-        if arg != '-':
+        arg = arg.replace(b('_'), b('-'))
+        if arg != b('-'):
             if len(arg) == 1:
-                arg = '-' + arg
+                arg = b('-') + arg
             else:
-                arg = '--' + arg
+                arg = b('--') + arg
         if isinstance(val, bool):
             if val:
                 cmd.append(arg)