Patchwork [stable] py3: use pycompat.bytestr() instead of pycompat.sysstr()

login
register
mail settings
Submitter Manuel Jacob
Date Nov. 19, 2019, 10:59 a.m.
Message ID <c5bcd946a34b77d7680d.1574161193@tmp>
Download mbox | patch
Permalink /patch/43353/
State Accepted
Headers show

Comments

Manuel Jacob - Nov. 19, 2019, 10:59 a.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1574161183 -3600
#      Tue Nov 19 11:59:43 2019 +0100
# Branch stable
# Node ID c5bcd946a34b77d7680d62ea329542a06d48b5df
# Parent  0f82b29f7494399c93920543ce65bf9258459cd5
py3: use pycompat.bytestr() instead of pycompat.sysstr()

pycompat.sysstr() doesn’t work because it doesn’t accept arguments of type
`type` and returns a unicode object on Python3, while the format string wants
a bytes-like object.
Yuya Nishihara - Nov. 19, 2019, 11:51 a.m.
On Tue, 19 Nov 2019 11:59:53 +0100, Manuel Jacob wrote:
> # HG changeset patch
> # User Manuel Jacob <me@manueljacob.de>
> # Date 1574161183 -3600
> #      Tue Nov 19 11:59:43 2019 +0100
> # Branch stable
> # Node ID c5bcd946a34b77d7680d62ea329542a06d48b5df
> # Parent  0f82b29f7494399c93920543ce65bf9258459cd5
> py3: use pycompat.bytestr() instead of pycompat.sysstr()
> 
> pycompat.sysstr() doesn’t work because it doesn’t accept arguments of type
> `type` and returns a unicode object on Python3, while the format string wants
> a bytes-like object.

Yup, sysstr() is bytes->str function. Queued, thanks.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1568,7 +1568,7 @@ 
             else:
                 raise error.ProgrammingError(
                     b"unsupported changeid '%s' of type %s"
-                    % (changeid, pycompat.sysstr(type(changeid)))
+                    % (changeid, pycompat.bytestr(type(changeid)))
                 )
 
             return context.changectx(self, rev, node)