##// END OF EJS Templates
ui: guard against UnicodeDecodeErrors in ui.wrap
Martin Geisler -
r9495:b2d65ee4 default
parent child Browse files
Show More
@@ -1278,9 +1278,12 b' def wrap(line, hangindent, width=78):'
1278 padding = '\n' + ' ' * hangindent
1278 padding = '\n' + ' ' * hangindent
1279 # To avoid corrupting multi-byte characters in line, we must wrap
1279 # To avoid corrupting multi-byte characters in line, we must wrap
1280 # a Unicode string instead of a bytestring.
1280 # a Unicode string instead of a bytestring.
1281 u = line.decode(encoding.encoding)
1281 try:
1282 w = padding.join(textwrap.wrap(u, width=width - hangindent))
1282 u = line.decode(encoding.encoding)
1283 return w.encode(encoding.encoding)
1283 w = padding.join(textwrap.wrap(u, width=width - hangindent))
1284 return w.encode(encoding.encoding)
1285 except UnicodeDecodeError:
1286 return padding.join(textwrap.wrap(line, width=width - hangindent))
1284
1287
1285 def iterlines(iterator):
1288 def iterlines(iterator):
1286 for chunk in iterator:
1289 for chunk in iterator:
General Comments 0
You need to be logged in to leave comments. Login now