changeset 44164:c443b9ba6f63 stable

py3: __repr__ needs to return str, not bytes Differential Revision: https://phab.mercurial-scm.org/D8089
author Kyle Lippincott <spectral@google.com>
date Thu, 02 Jan 2020 11:04:18 -0800
parents eecc005229ff
children 12491abf93bd
files mercurial/bundle2.py mercurial/linelog.py mercurial/manifest.py mercurial/patch.py
diffstat 4 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Tue Feb 04 12:07:37 2020 +0100
+++ b/mercurial/bundle2.py	Thu Jan 02 11:04:18 2020 -0800
@@ -1013,6 +1013,7 @@
         self._generated = None
         self.mandatory = mandatory
 
+    @encoding.strmethod
     def __repr__(self):
         cls = b"%s.%s" % (self.__class__.__module__, self.__class__.__name__)
         return b'<%s object at %x; id: %s; type: %s; mandatory: %s>' % (
--- a/mercurial/linelog.py	Tue Feb 04 12:07:37 2020 +0100
+++ b/mercurial/linelog.py	Thu Jan 02 11:04:18 2020 -0800
@@ -255,7 +255,7 @@
         )
 
     def __repr__(self):
-        return b'<linelog at %s: maxrev=%d size=%d>' % (
+        return '<linelog at %s: maxrev=%d size=%d>' % (
             hex(id(self)),
             self._maxrev,
             len(self._program),
--- a/mercurial/manifest.py	Tue Feb 04 12:07:37 2020 +0100
+++ b/mercurial/manifest.py	Thu Jan 02 11:04:18 2020 -0800
@@ -21,6 +21,7 @@
 )
 from .pycompat import getattr
 from . import (
+    encoding,
     error,
     mdiff,
     pathutil,
@@ -867,9 +868,10 @@
         self._loadalllazy()
         return not self._dirs or all(m._isempty() for m in self._dirs.values())
 
+    @encoding.strmethod
     def __repr__(self):
         return (
-            b'<treemanifest dir=%s, node=%s, loaded=%s, dirty=%s at 0x%x>'
+            b'<treemanifest dir=%s, node=%s, loaded=%r, dirty=%r at 0x%x>'
             % (
                 self._dir,
                 hex(self._node),
--- a/mercurial/patch.py	Tue Feb 04 12:07:37 2020 +0100
+++ b/mercurial/patch.py	Thu Jan 02 11:04:18 2020 -0800
@@ -1090,6 +1090,7 @@
     def filename(self):
         return self.header.filename()
 
+    @encoding.strmethod
     def __repr__(self):
         return b'<hunk %r@%d>' % (self.filename(), self.fromline)