D2269: py3: use pycompat.bytestr instead of str for converting errors to bytes

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Wed Feb 14 08:32:18 EST 2018


yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> transplant.py:314
>                  self.log(user, date, message, p1, p2, merge=merge)
> -                self.ui.write(str(inst) + '\n')
> +                self.ui.write(pycompat.bytestr(inst) + '\n')
>                  raise TransplantError(_('fix up the working directory and run '

Use `util.forcebytestr()` to stringify an exception object of unknown encoding.

> patch.py:1462
>                  raise PatchError(_('could not decode "%s" binary patch: %s')
> -                                 % (self._fname, str(e)))
> +                                 % (self._fname, pycompat.bytestr(e)))
>              line = getline(lr, self.hunk)

Here `bytestr()` is probably fine, but could be `forcebytestr()`, too.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers, yuja
Cc: yuja, mercurial-devel


More information about the Mercurial-devel mailing list