Patchwork [06,of,11] bdiff: coerce to bytes() not str() in pure code

login
register
mail settings
Submitter Augie Fackler
Date March 26, 2017, 10:36 p.m.
Message ID <48144fe2d912b7d9fc30.1490567800@imladris.local>
Download mbox | patch
Permalink /patch/19705/
State Accepted
Headers show

Comments

Augie Fackler - March 26, 2017, 10:36 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1490567279 14400
#      Sun Mar 26 18:27:59 2017 -0400
# Node ID 48144fe2d912b7d9fc300955d0c881aceead6930
# Parent  d5dcfa6b2e20183ba2d6e439a23f5f2f4bf7981e
bdiff: coerce to bytes() not str() in pure code
Pulkit Goyal - March 27, 2017, 6:17 a.m.
Yuya also has couple of patches in his series which deal with the same
issue.
https://patchwork.mercurial-scm.org/patch/19678/
https://patchwork.mercurial-scm.org/patch/19679/


On Mon, Mar 27, 2017 at 4:06 AM, Augie Fackler <raf@durin42.com> wrote:

> # HG changeset patch
> # User Augie Fackler <raf@durin42.com>
> # Date 1490567279 14400
> #      Sun Mar 26 18:27:59 2017 -0400
> # Node ID 48144fe2d912b7d9fc300955d0c881aceead6930
> # Parent  d5dcfa6b2e20183ba2d6e439a23f5f2f4bf7981e
> bdiff: coerce to bytes() not str() in pure code
>
> diff --git a/mercurial/pure/bdiff.py b/mercurial/pure/bdiff.py
> --- a/mercurial/pure/bdiff.py
> +++ b/mercurial/pure/bdiff.py
> @@ -59,7 +59,7 @@ def _tostring(c):
>      if type(c) is array.array:
>          # this copy overhead isn't ideal
>          return c.tostring()
> -    return str(c)
> +    return bytes(c)
>
>  def bdiff(a, b):
>      a = _tostring(a).splitlines(True)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/pure/bdiff.py b/mercurial/pure/bdiff.py
--- a/mercurial/pure/bdiff.py
+++ b/mercurial/pure/bdiff.py
@@ -59,7 +59,7 @@  def _tostring(c):
     if type(c) is array.array:
         # this copy overhead isn't ideal
         return c.tostring()
-    return str(c)
+    return bytes(c)
 
 def bdiff(a, b):
     a = _tostring(a).splitlines(True)