Mercurial > public > mercurial-scm > hg
comparison mercurial/templatefilters.py @ 36497:b2e54b257832
templatefilters: use encoding.unifromlocal/unitolocal() for py3 compatibility
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 01 Mar 2018 06:38:37 -0500 |
parents | 9ee10b3284da |
children | b546181ae451 |
comparison
equal
deleted
inserted
replaced
36496:7af7443877da | 36497:b2e54b257832 |
---|---|
150 def findparas(): | 150 def findparas(): |
151 start = 0 | 151 start = 0 |
152 while True: | 152 while True: |
153 m = para_re.search(text, start) | 153 m = para_re.search(text, start) |
154 if not m: | 154 if not m: |
155 uctext = unicode(text[start:], encoding.encoding) | 155 uctext = encoding.unifromlocal(text[start:]) |
156 w = len(uctext) | 156 w = len(uctext) |
157 while 0 < w and uctext[w - 1].isspace(): | 157 while 0 < w and uctext[w - 1].isspace(): |
158 w -= 1 | 158 w -= 1 |
159 yield (uctext[:w].encode(encoding.encoding), | 159 yield (encoding.unitolocal(uctext[:w]), |
160 uctext[w:].encode(encoding.encoding)) | 160 encoding.unitolocal(uctext[w:])) |
161 break | 161 break |
162 yield text[start:m.start(0)], m.group(1) | 162 yield text[start:m.start(0)], m.group(1) |
163 start = m.end(1) | 163 start = m.end(1) |
164 | 164 |
165 return "".join([util.wrap(space_re.sub(' ', util.wrap(para, width)), | 165 return "".join([util.wrap(space_re.sub(' ', util.wrap(para, width)), |