py3: fully fix bundlepart.__repr__ to return str not bytes stable
authorKyle Lippincott <spectral@google.com>
Thu, 06 Feb 2020 15:46:55 -0800
branchstable
changeset 44256 74172a234dd3
parent 44255 541a509a47a8
child 44278 27787a43712f
child 44285 63d84c18247a
py3: fully fix bundlepart.__repr__ to return str not bytes My previous fix did not fully fix the issue: it would attempt to use %-formatting to combine two strs into a bytes, which won't work. Let's just switch the entire function to operating in strs. This can cause a small output difference that will likely not be noticed since no one noticed that the method wasn't working at all before: if `id` or `type` are not-None, they'll be shown as `b'val'` instead of `val`. Since this is a debugging aid and these strings shouldn't be shown to the user, slightly rough output is most likely fine and it's likely not worthwhile to add the necessary conditionals to marginally improve it. Differential Revision: https://phab.mercurial-scm.org/D8091
mercurial/bundle2.py
--- a/mercurial/bundle2.py	Sun Nov 17 01:18:14 2019 +0100
+++ b/mercurial/bundle2.py	Thu Feb 06 15:46:55 2020 -0800
@@ -1013,10 +1013,9 @@
         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>' % (
+        cls = "%s.%s" % (self.__class__.__module__, self.__class__.__name__)
+        return '<%s object at %x; id: %s; type: %s; mandatory: %s>' % (
             cls,
             id(self),
             self.id,