Patchwork [2,of,8,py3] minirst: use bytes.strip instead of str.strip

login
register
mail settings
Submitter Augie Fackler
Date May 28, 2017, 8:58 p.m.
Message ID <37a72a324f8cd47da657.1496005138@imladris.local>
Download mbox | patch
Permalink /patch/21002/
State Accepted
Headers show

Comments

Augie Fackler - May 28, 2017, 8:58 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1495993302 14400
#      Sun May 28 13:41:42 2017 -0400
# Node ID 37a72a324f8cd47da65756b888b5e0b8cfd600ae
# Parent  544f6b7f4a3d2542942c733fb3f82bfd8a5a9867
minirst: use bytes.strip instead of str.strip

Patch

diff --git a/mercurial/minirst.py b/mercurial/minirst.py
--- a/mercurial/minirst.py
+++ b/mercurial/minirst.py
@@ -452,7 +452,7 @@  def findadmonitions(blocks, admonitions=
 }
 
 def formatoption(block, width):
-    desc = ' '.join(map(str.strip, block['lines']))
+    desc = ' '.join(map(bytes.strip, block['lines']))
     colwidth = encoding.colwidth(block['optstr'])
     usablewidth = width - 1
     hanging = block['optstrwidth']
@@ -474,7 +474,7 @@  def formatblock(block, width):
         hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip())
 
         defindent = indent + hang * ' '
-        text = ' '.join(map(str.strip, block['lines']))
+        text = ' '.join(map(bytes.strip, block['lines']))
         return '%s\n%s\n' % (indent + admonition,
                              util.wrap(text, width=width,
                                        initindent=defindent,
@@ -512,7 +512,7 @@  def formatblock(block, width):
         term = indent + block['lines'][0]
         hang = len(block['lines'][-1]) - len(block['lines'][-1].lstrip())
         defindent = indent + hang * ' '
-        text = ' '.join(map(str.strip, block['lines'][1:]))
+        text = ' '.join(map(bytes.strip, block['lines'][1:]))
         return '%s\n%s\n' % (term, util.wrap(text, width=width,
                                              initindent=defindent,
                                              hangindent=defindent))
@@ -567,7 +567,7 @@  def formathtml(blocks):
 
         if btype == 'admonition':
             admonition = escape(_admonitiontitles[b['admonitiontitle']])
-            text = escape(' '.join(map(str.strip, lines)))
+            text = escape(' '.join(map(bytes.strip, lines)))
             out.append('<p>\n<b>%s</b> %s\n</p>\n' % (admonition, text))
         elif btype == 'paragraph':
             out.append('<p>\n%s\n</p>\n' % escape('\n'.join(lines)))
@@ -597,7 +597,7 @@  def formathtml(blocks):
         elif btype == 'definition':
             openlist('dl', level)
             term = escape(lines[0])
-            text = escape(' '.join(map(str.strip, lines[1:])))
+            text = escape(' '.join(map(bytes.strip, lines[1:])))
             out.append(' <dt>%s\n <dd>%s\n' % (term, text))
         elif btype == 'bullet':
             bullet, head = lines[0].split(' ', 1)
@@ -609,12 +609,12 @@  def formathtml(blocks):
         elif btype == 'field':
             openlist('dl', level)
             key = escape(b['key'])
-            text = escape(' '.join(map(str.strip, lines)))
+            text = escape(' '.join(map(bytes.strip, lines)))
             out.append(' <dt>%s\n <dd>%s\n' % (key, text))
         elif btype == 'option':
             openlist('dl', level)
             opt = escape(b['optstr'])
-            desc = escape(' '.join(map(str.strip, lines)))
+            desc = escape(' '.join(map(bytes.strip, lines)))
             out.append(' <dt>%s\n <dd>%s\n' % (opt, desc))
 
         # close lists if indent level of next block is lower