[PATCH 4 of 7] py3: fix slicing of byte string in revlog.compress()

Yuya Nishihara yuya at tcha.org
Sun Mar 26 07:59:47 EDT 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1490515926 -32400
#      Sun Mar 26 17:12:06 2017 +0900
# Node ID 435eb9e60147c1cfac43b204b637b8ac8d4830c0
# Parent  ea2d8321f3209e5b817353e2e15f7ba6b1b472a5
py3: fix slicing of byte string in revlog.compress()

I tried .startswith('\0'), but data wasn't always a bytes nor a bytearray.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1488,7 +1488,7 @@ class revlog(object):
             # The revlog compressor added the header in the returned data.
             return '', compressed
 
-        if data[0] == '\0':
+        if data[0:1] == '\0':
             return '', data
         return 'u', data
 


More information about the Mercurial-devel mailing list