]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/vint.py
index: fix -H option
[bup.git] / lib / bup / vint.py
index cb7225d88e3ddf801c5ce727b3f60560892ae804..086cb302087d8edae343631c04c68a87440c35f8 100644 (file)
@@ -36,6 +36,7 @@ def read_vuint(port):
     c = port.read(1)
     if not c:
         raise EOFError('encountered EOF while reading vuint')
+    assert isinstance(c, bytes)
     if ord(c) == 0:
         return 0
     result = 0
@@ -79,22 +80,22 @@ def read_vint(port):
     c = port.read(1)
     if not c:
         raise EOFError('encountered EOF while reading vint')
+    assert isinstance(c, bytes)
     negative = False
     result = 0
     offset = 0
     # Handle first byte with sign bit specially.
-    if c:
-        b = ord(c)
-        if b & 0x40:
-            negative = True
-        result |= (b & 0x3f)
-        if b & 0x80:
-            offset += 6
-            c = port.read(1)
-        elif negative:
-            return -result
-        else:
-            return result
+    b = ord(c)
+    if b & 0x40:
+        negative = True
+    result |= (b & 0x3f)
+    if b & 0x80:
+        offset += 6
+        c = port.read(1)
+    elif negative:
+        return -result
+    else:
+        return result
     while True:
         b = ord(c)
         if b & 0x80: