Patchwork [04,of,11] changelog: coerce data to write to bytes(), not str()

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

Comments

Augie Fackler - March 26, 2017, 10:36 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1490567095 14400
#      Sun Mar 26 18:24:55 2017 -0400
# Node ID 54631fab906cb662e370ce313a0395292f7dfa15
# Parent  25355685cfaced26214c1fb89d191c3705dc52c7
changelog: coerce data to write to bytes(), not str()

I'm pretty sure we never get an int in here, so this should be safe.
Pulkit Goyal - March 27, 2017, 6:18 a.m.
Yuya has a same one https://patchwork.mercurial-scm.org/patch/19680/

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 1490567095 14400
> #      Sun Mar 26 18:24:55 2017 -0400
> # Node ID 54631fab906cb662e370ce313a0395292f7dfa15
> # Parent  25355685cfaced26214c1fb89d191c3705dc52c7
> changelog: coerce data to write to bytes(), not str()
>
> I'm pretty sure we never get an int in here, so this should be safe.
>
> diff --git a/mercurial/changelog.py b/mercurial/changelog.py
> --- a/mercurial/changelog.py
> +++ b/mercurial/changelog.py
> @@ -120,7 +120,7 @@ class appender(object):
>          return ret
>
>      def write(self, s):
> -        self.data.append(str(s))
> +        self.data.append(bytes(s))
>          self.offset += len(s)
>          self._end += len(s)
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -120,7 +120,7 @@  class appender(object):
         return ret
 
     def write(self, s):
-        self.data.append(str(s))
+        self.data.append(bytes(s))
         self.offset += len(s)
         self._end += len(s)