diff mercurial/pure/base85.py @ 43077:687b865b95ad

formatting: byteify all mercurial/ and hgext/ string literals Done with python3.7 contrib/byteify-strings.py -i $(hg files 'set:mercurial/**.py - mercurial/thirdparty/** + hgext/**.py - hgext/fsmonitor/pywatchman/** - mercurial/__init__.py') black -l 80 -t py33 -S $(hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**') # skip-blame mass-reformatting only Differential Revision: https://phab.mercurial-scm.org/D6972
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:48:39 -0400
parents 2372284d9457
children 4394687b298b
line wrap: on
line diff
--- a/mercurial/pure/base85.py	Sun Oct 06 09:45:02 2019 -0400
+++ b/mercurial/pure/base85.py	Sun Oct 06 09:48:39 2019 -0400
@@ -12,8 +12,8 @@
 from .. import pycompat
 
 _b85chars = pycompat.bytestr(
-    "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
-    "ghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"
+    b"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
+    b"ghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"
 )
 _b85chars2 = [(a + b) for a in _b85chars for b in _b85chars]
 _b85dec = {}
@@ -29,11 +29,11 @@
     l = len(text)
     r = l % 4
     if r:
-        text += '\0' * (4 - r)
+        text += b'\0' * (4 - r)
     longs = len(text) >> 2
-    words = struct.unpack('>%dL' % longs, text)
+    words = struct.unpack(b'>%dL' % longs, text)
 
-    out = ''.join(
+    out = b''.join(
         _b85chars[(word // 52200625) % 85]
         + _b85chars2[(word // 7225) % 7225]
         + _b85chars2[word % 7225]
@@ -67,10 +67,10 @@
                 acc = acc * 85 + _b85dec[c]
             except KeyError:
                 raise ValueError(
-                    'bad base85 character at position %d' % (i + j)
+                    b'bad base85 character at position %d' % (i + j)
                 )
         if acc > 4294967295:
-            raise ValueError('Base85 overflow in hunk starting at byte %d' % i)
+            raise ValueError(b'Base85 overflow in hunk starting at byte %d' % i)
         out.append(acc)
 
     # Pad final chunk if necessary
@@ -81,7 +81,7 @@
             acc += 0xFFFFFF >> (cl - 2) * 8
         out[-1] = acc
 
-    out = struct.pack('>%dL' % (len(out)), *out)
+    out = struct.pack(b'>%dL' % (len(out)), *out)
     if cl:
         out = out[: -(5 - cl)]