[Commented On] D8639: py3: fix broken man page generation, it was generating `(default: NUL*)`

spectral (Kyle Lippincott) phabricator at mercurial-scm.org
Thu Jun 18 17:51:16 UTC 2020


spectral added inline comments.

INLINE COMMENTS

> mjacob wrote in gendoc.py:90
> Isn’t `bool(defaulttmpl)` always true?

I assumed it wasn't and that this was a way of checking whether the translation had the string. But now that I'm reading it again, I think it's a different way of writing `desc += _(b" (default: %s)") % bytes(default) if default else b""`, so I've made this non-conditional.

> mjacob wrote in gendoc.py:92
> I think it’s safer to use 'ascii' here.
> 
> On Python 2, `repr(default)` is likely to return bytes and therefore will attempt to decode it with 'ascii' before encoding it with 'latin1'.
> 
> In general, I don’t think it is guaranteed that the output is expected to be latin1-encoded. If we ever have non-ASCII default values, we should fail early instead of producing mojibake.
> 
> An alternative to your code would be to use `pycompat.bytestr`. I don’t have a preference. An theoretical advantage is that is works correctly with `bytearray`, if we ever use it for default values. ;)

Yeah, now that I look closer, I was confused by the use of latin1 above. Switched this to stringutil.forcebytestr.

REPOSITORY
  rHG Mercurial

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

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

To: spectral, #hg-reviewers
Cc: mjacob, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200618/e3b909bc/attachment-0002.html>


More information about the Mercurial-patches mailing list