Patchwork D7682: patch: make __repr__() return str

login
register
mail settings
Submitter phabricator
Date Dec. 17, 2019, 4:46 a.m.
Message ID <differential-rev-PHID-DREV-zzrtivluoj6paggckvqi-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43897/
State Superseded
Headers show

Comments

phabricator - Dec. 17, 2019, 4:46 a.m.
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Caught by pytype:
  
    line 969, in __repr__: Function bytes.join was called with the wrong arguments [wrong-arg-types]
    Expected: (self, iterable: Iterable[bytes])
    Actually passed: (self, iterable: Iterator[str])

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7682

AFFECTED FILES
  mercurial/patch.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 17, 2019, 8:26 a.m.
dlax added inline comments.
dlax accepted this revision.

INLINE COMMENTS

> patch.py:966
>      def __repr__(self):
> -        return b'<header %s>' % (b' '.join(map(repr, self.files())))
> +        return '<header %s>' % (' '.join(map(repr, self.files())))
>  

Somehow unrelated, but `self.files()` returns a list of bytes I think. So this will lead to something like `"<header b'file' b'file'>"`. But maybe this is okay? (at least it wouldn't crash now)

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7682/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7682

To: mharbison72, #hg-reviewers, pulkit, dlax
Cc: dlax, mercurial-devel

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -963,7 +963,7 @@ 
         return self.files()[-1]
 
     def __repr__(self):
-        return b'<header %s>' % (b' '.join(map(repr, self.files())))
+        return '<header %s>' % (' '.join(map(repr, self.files())))
 
     def isnewfile(self):
         return any(self.newfile_re.match(h) for h in self.header)