[PATCH 09 of 10 py3] help: work around textwrap.dedent() only working on strings

Augie Fackler raf at durin42.com
Mon May 29 10:32:31 EDT 2017


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1496001067 14400
#      Sun May 28 15:51:07 2017 -0400
# Node ID f1be99397daee2fa8bd9d04cb1296cb7e0260c0d
# Parent  c52ab13885c505252bddf459e3ef86fe1fb8f560
help: work around textwrap.dedent() only working on strings

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -270,7 +270,8 @@ def makeitemsdoc(ui, topic, doc, marker,
             continue
         text = gettext(text)
         if dedent:
-            text = textwrap.dedent(text)
+            # Abuse latin1 to use textwrap.dedent() on bytes.
+            text = textwrap.dedent(text.decode('latin1')).encode('latin1')
         lines = text.splitlines()
         doclines = [(lines[0])]
         for l in lines[1:]:


More information about the Mercurial-devel mailing list