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

login
register
mail settings
Submitter Yuya Nishihara
Date March 26, 2017, 11:59 a.m.
Message ID <435eb9e60147c1cfac43.1490529587@mimosa>
Download mbox | patch
Permalink /patch/19681/
State Accepted
Headers show

Comments

Yuya Nishihara - March 26, 2017, 11:59 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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