Patchwork [1,of,4,py3] util: pass encoding.[encoding|encodingmode] as unicodes

login
register
mail settings
Submitter Pulkit Goyal
Date March 12, 2017, 5:19 p.m.
Message ID <0d6acdc8385488a3dfd1.1489339188@pulkit-goyal>
Download mbox | patch
Permalink /patch/19166/
State Accepted
Headers show

Comments

Pulkit Goyal - March 12, 2017, 5:19 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1489284313 -19800
#      Sun Mar 12 07:35:13 2017 +0530
# Node ID 0d6acdc8385488a3dfd18cb413af4f9a2ba71512
# Parent  5ffb1db4197ad77c7ea9449b7e4f40c7cfa9cebc
util: pass encoding.[encoding|encodingmode] as unicodes

We need to pass str to encode() and decode().

Patch

diff -r 5ffb1db4197a -r 0d6acdc83854 mercurial/util.py
--- a/mercurial/util.py	Sun Mar 12 07:09:18 2017 +0530
+++ b/mercurial/util.py	Sun Mar 12 07:35:13 2017 +0530
@@ -2241,13 +2241,16 @@ 
     if width <= maxindent:
         # adjust for weird terminal size
         width = max(78, maxindent + 1)
-    line = line.decode(encoding.encoding, encoding.encodingmode)
-    initindent = initindent.decode(encoding.encoding, encoding.encodingmode)
-    hangindent = hangindent.decode(encoding.encoding, encoding.encodingmode)
+    line = line.decode(pycompat.sysstr(encoding.encoding),
+                    pycompat.sysstr(encoding.encodingmode))
+    initindent = initindent.decode(pycompat.sysstr(encoding.encoding),
+                    pycompat.sysstr(encoding.encodingmode))
+    hangindent = hangindent.decode(pycompat.sysstr(encoding.encoding),
+                    pycompat.sysstr(encoding.encodingmode))
     wrapper = MBTextWrapper(width=width,
                             initial_indent=initindent,
                             subsequent_indent=hangindent)
-    return wrapper.fill(line).encode(encoding.encoding)
+    return wrapper.fill(line).encode(pycompat.sysstr(encoding.encoding))
 
 if (pyplatform.python_implementation() == 'CPython' and
     sys.version_info < (3, 0)):