Patchwork [1,of,2,STABLE] pure: use string for exception in the pure version of base85

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 16, 2019, 11:33 p.m.
Message ID <c9224e21c5650b5884a5.1573947223@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/43319/
State Accepted
Headers show

Comments

Pierre-Yves David - Nov. 16, 2019, 11:33 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1573931269 -3600
#      Sat Nov 16 20:07:49 2019 +0100
# Branch stable
# Node ID c9224e21c5650b5884a5f69536c593fda7ee5055
# Parent  856cce0c255cc6ffbe164764cc152e3011c59fd7
# EXP-Topic fix-py3-pure-b85
# Available At https://dev.heptapod.net/octobus/mercurial-devel/
#              hg pull https://dev.heptapod.net/octobus/mercurial-devel/ -r c9224e21c565
pure: use string for exception in the pure version of base85

Without this change, running the test with python3 and --pure gives the
following error::

  --- /home/marmoute/src/mercurial-dev/tests/test-import-git.t
  +++ /home/marmoute/src/mercurial-dev/tests/test-import-git.t.err
  @@ -518,7 +518,7 @@
     >
     > EOF
     applying patch from stdin
  -  abort: could not decode "binary2" binary patch: bad base85 character at position 6
  +  abort: could not decode "binary2" binary patch: b'bad base85 character at position 6'
     [255]

     $ hg revert -aq

To make the cext implementation, we use a "native" string for the exception.
This fix the test failure.
Gregory Szorc - Nov. 17, 2019, 2:01 a.m.
On Sat, Nov 16, 2019 at 3:37 PM Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1573931269 -3600
> #      Sat Nov 16 20:07:49 2019 +0100
> # Branch stable
> # Node ID c9224e21c5650b5884a5f69536c593fda7ee5055
> # Parent  856cce0c255cc6ffbe164764cc152e3011c59fd7
> # EXP-Topic fix-py3-pure-b85
> # Available At https://dev.heptapod.net/octobus/mercurial-devel/
> #              hg pull https://dev.heptapod.net/octobus/mercurial-devel/
> -r c9224e21c565
> pure: use string for exception in the pure version of base85
>

Queued for stable.


>
> Without this change, running the test with python3 and --pure gives the
> following error::
>
>   --- /home/marmoute/src/mercurial-dev/tests/test-import-git.t
>   +++ /home/marmoute/src/mercurial-dev/tests/test-import-git.t.err
>   @@ -518,7 +518,7 @@
>      >
>      > EOF
>      applying patch from stdin
>   -  abort: could not decode "binary2" binary patch: bad base85 character
> at position 6
>   +  abort: could not decode "binary2" binary patch: b'bad base85
> character at position 6'
>      [255]
>
>      $ hg revert -aq
>
> To make the cext implementation, we use a "native" string for the
> exception.
> This fix the test failure.
>
> diff --git a/mercurial/pure/base85.py b/mercurial/pure/base85.py
> --- a/mercurial/pure/base85.py
> +++ b/mercurial/pure/base85.py
> @@ -67,7 +67,7 @@ def b85decode(text):
>                  acc = acc * 85 + _b85dec[c]
>              except KeyError:
>                  raise ValueError(
> -                    b'bad base85 character at position %d' % (i + j)
> +                    'bad base85 character at position %d' % (i + j)
>                  )
>          if acc > 4294967295:
>              raise ValueError(b'Base85 overflow in hunk starting at byte
> %d' % i)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/pure/base85.py b/mercurial/pure/base85.py
--- a/mercurial/pure/base85.py
+++ b/mercurial/pure/base85.py
@@ -67,7 +67,7 @@  def b85decode(text):
                 acc = acc * 85 + _b85dec[c]
             except KeyError:
                 raise ValueError(
-                    b'bad base85 character at position %d' % (i + j)
+                    'bad base85 character at position %d' % (i + j)
                 )
         if acc > 4294967295:
             raise ValueError(b'Base85 overflow in hunk starting at byte %d' % i)