[PATCH] py3: change explicit conversion from str to bytes

Yuya Nishihara yuya at tcha.org
Fri Mar 17 08:30:55 EDT 2017


On Fri, 17 Mar 2017 17:13:53 +0530, Rishabh Madan wrote:
> # HG changeset patch
> # User Rishabh Madan <rishabhmadan96 at gmail.com>
> # Date 1489746142 -19800
> #      Fri Mar 17 15:52:22 2017 +0530
> # Node ID 2aac5780c5b3c30602ca128cfeb6e38a42f2c0fb
> # Parent  a5bad127128d8f60060be53d161acfa7a32a17d5
> py3: change explicit conversion from str to bytes
> 
> diff -r a5bad127128d -r 2aac5780c5b3 mercurial/commands.py
> --- a/mercurial/commands.py	Wed Mar 15 15:48:57 2017 -0700
> +++ b/mercurial/commands.py	Fri Mar 17 15:52:22 2017 +0530
> @@ -1813,7 +1813,7 @@
>      matched = False
>      for section, name, value in ui.walkconfig(untrusted=untrusted):
>          source = ui.configsource(section, name, untrusted)
> -        value = str(value)
> +        value = bytes(value)

On Python 3, bytes() can't be used to stringify arbitrary objects, e.g.

  >>> bytes(2)
  b'\x00\x00'

pycompat.bytestr() should be usable here.


More information about the Mercurial-devel mailing list