Patchwork [1,of,7] py3: make encoding.encoding unicodes to pass into encode()

login
register
mail settings
Submitter Pulkit Goyal
Date May 3, 2017, 9:59 a.m.
Message ID <2069dd90c6afe4e13ab7.1493805560@pulkit-goyal>
Download mbox | patch
Permalink /patch/20396/
State Accepted
Headers show

Comments

Pulkit Goyal - May 3, 2017, 9:59 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1491629557 -19800
#      Sat Apr 08 11:02:37 2017 +0530
# Node ID 2069dd90c6afe4e13ab73cbbf572fd4b50680def
# Parent  5f8450df55625fb0be8e40eacb662717fef33de2
py3: make encoding.encoding unicodes to pass into encode()
Yuya Nishihara - May 4, 2017, 2:03 a.m.
On Wed, 03 May 2017 15:29:20 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1491629557 -19800
> #      Sat Apr 08 11:02:37 2017 +0530
> # Node ID 2069dd90c6afe4e13ab73cbbf572fd4b50680def
> # Parent  5f8450df55625fb0be8e40eacb662717fef33de2
> py3: make encoding.encoding unicodes to pass into encode()
> 
> diff -r 5f8450df5562 -r 2069dd90c6af mercurial/scmutil.py
> --- a/mercurial/scmutil.py	Tue May 02 02:05:39 2017 +0200
> +++ b/mercurial/scmutil.py	Sat Apr 08 11:02:37 2017 +0530
> @@ -212,7 +212,8 @@
>                  reason = inst.reason
>              if isinstance(reason, unicode):
>                  # SSLError of Python 2.7.9 contains a unicode
> -                reason = reason.encode(encoding.encoding, 'replace')
> +                reason = reason.encode(pycompat.sysstr(encoding.encoding),
> +                                        'replace')

Perhaps we can use encoding.unitolocal() instead.

Patch

diff -r 5f8450df5562 -r 2069dd90c6af mercurial/scmutil.py
--- a/mercurial/scmutil.py	Tue May 02 02:05:39 2017 +0200
+++ b/mercurial/scmutil.py	Sat Apr 08 11:02:37 2017 +0530
@@ -212,7 +212,8 @@ 
                 reason = inst.reason
             if isinstance(reason, unicode):
                 # SSLError of Python 2.7.9 contains a unicode
-                reason = reason.encode(encoding.encoding, 'replace')
+                reason = reason.encode(pycompat.sysstr(encoding.encoding),
+                                        'replace')
             ui.warn(_("abort: error: %s\n") % reason)
         elif (util.safehasattr(inst, "args")
               and inst.args and inst.args[0] == errno.EPIPE):