[PATCH 6 of 7] py3: slice over bytes to prevent getting ascii values

Yuya Nishihara yuya at tcha.org
Wed May 3 22:16:10 EDT 2017


On Wed, 03 May 2017 15:29:25 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit at gmail.com>
> # Date 1493320932 -19800
> #      Fri Apr 28 00:52:12 2017 +0530
> # Node ID 07bd56e106d472c526d99caf3154c2d2727f8d79
> # Parent  4b5015610049afd91ae99357657a6fad7c234547
> py3: slice over bytes to prevent getting ascii values

Can you check if bytestr is usable?

> diff -r 4b5015610049 -r 07bd56e106d4 mercurial/changelog.py
> --- a/mercurial/changelog.py	Fri Apr 21 00:53:38 2017 +0530
> +++ b/mercurial/changelog.py	Fri Apr 28 00:52:12 2017 +0530
> @@ -190,7 +190,7 @@
>  
>          # The list of files may be empty. Which means nl3 is the first of the
>          # double newline that precedes the description.
> -        if text[nl3 + 1] == '\n':
> +        if text[nl3 + 1:nl3 + 2] == '\n':

I think this is simple enough to not use bytestr helper.

> --- a/mercurial/templater.py	Fri Apr 21 00:53:38 2017 +0530
> +++ b/mercurial/templater.py	Fri Apr 28 00:52:12 2017 +0530
> @@ -54,7 +54,7 @@
>      with term if specified"""
>      pos = start
>      while pos < end:
> -        c = program[pos]
> +        c = program[pos:pos + 1]

but here we have too many [x:x + 1] so we should use bytestr instead.


More information about the Mercurial-devel mailing list