Patchwork [2,of,8] py3: replace bytes[n] with bytes[n:n + 1] in patch.py where needed

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 3, 2017, 2:36 p.m.
Message ID <03f65a976779da5cfb8a.1504449380@mimosa>
Download mbox | patch
Permalink /patch/23641/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 3, 2017, 2:36 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1504423160 -32400
#      Sun Sep 03 16:19:20 2017 +0900
# Node ID 03f65a976779da5cfb8adf475a01ac0e14e42761
# Parent  313ecdde1470bb3a0e1f9beced7e596b8004e456
py3: replace bytes[n] with bytes[n:n + 1] in patch.py where needed

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1693,7 +1693,7 @@  def pathtransform(path, strip, prefix):
                              (count, strip, path))
         i += 1
         # consume '//' in the path
-        while i < pathlen - 1 and path[i] == '/':
+        while i < pathlen - 1 and path[i:i + 1] == '/':
             i += 1
         count -= 1
     return path[:i].lstrip(), prefix + path[i:].rstrip()
@@ -1788,7 +1788,7 @@  def scanpatch(fp):
             else:
                 lr.push(fromfile)
             yield 'file', header
-        elif line[0] == ' ':
+        elif line[0:1] == ' ':
             yield 'context', scanwhile(line, lambda l: l[0] in ' \\')
         elif line[0] in '-+':
             yield 'hunk', scanwhile(line, lambda l: l[0] in '-+\\')