Patchwork [2,of,4] py3: replace str() with pycompat.bytestr()

login
register
mail settings
Submitter Pulkit Goyal
Date April 7, 2017, 10:59 a.m.
Message ID <c08552f3a4ab883aac25.1491562778@pulkit-goyal>
Download mbox | patch
Permalink /patch/19996/
State Accepted
Headers show

Comments

Pulkit Goyal - April 7, 2017, 10:59 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1491552995 -19800
#      Fri Apr 07 13:46:35 2017 +0530
# Node ID c08552f3a4ab883aac255bc7d8efb7637ba245d8
# Parent  6b32872e4896993efe0abcc13b6d9c4c9b8687b7
py3: replace str() with pycompat.bytestr()
Yuya Nishihara - April 7, 2017, 12:15 p.m.
On Fri, 07 Apr 2017 16:29:38 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1491552995 -19800
> #      Fri Apr 07 13:46:35 2017 +0530
> # Node ID c08552f3a4ab883aac255bc7d8efb7637ba245d8
> # Parent  6b32872e4896993efe0abcc13b6d9c4c9b8687b7
> py3: replace str() with pycompat.bytestr()
> 
> diff -r 6b32872e4896 -r c08552f3a4ab mercurial/hg.py
> --- a/mercurial/hg.py	Fri Apr 07 13:45:33 2017 +0530
> +++ b/mercurial/hg.py	Fri Apr 07 13:46:35 2017 +0530
> @@ -31,6 +31,7 @@
>      merge as mergemod,
>      node,
>      phases,
> +    pycompat,
>      repoview,
>      scmutil,
>      sshpeer,
> @@ -103,7 +104,7 @@
>      if u.fragment:
>          branch = u.fragment
>          u.fragment = None
> -    return str(u), (branch, branches or [])
> +    return pycompat.bytestr(u), (branch, branches or [])

Could be bytes(u) since util.url implements __bytes__().

Patch

diff -r 6b32872e4896 -r c08552f3a4ab mercurial/hg.py
--- a/mercurial/hg.py	Fri Apr 07 13:45:33 2017 +0530
+++ b/mercurial/hg.py	Fri Apr 07 13:46:35 2017 +0530
@@ -31,6 +31,7 @@ 
     merge as mergemod,
     node,
     phases,
+    pycompat,
     repoview,
     scmutil,
     sshpeer,
@@ -103,7 +104,7 @@ 
     if u.fragment:
         branch = u.fragment
         u.fragment = None
-    return str(u), (branch, branches or [])
+    return pycompat.bytestr(u), (branch, branches or [])
 
 schemes = {
     'bundle': bundlerepo,
diff -r 6b32872e4896 -r c08552f3a4ab mercurial/util.py
--- a/mercurial/util.py	Fri Apr 07 13:45:33 2017 +0530
+++ b/mercurial/util.py	Fri Apr 07 13:46:35 2017 +0530
@@ -2799,7 +2799,7 @@ 
         user, passwd = self.user, self.passwd
         try:
             self.user, self.passwd = None, None
-            s = str(self)
+            s = pycompat.bytestr(self)
         finally:
             self.user, self.passwd = user, passwd
         if not self.user:
@@ -2854,7 +2854,7 @@ 
     u = url(u)
     if u.passwd:
         u.passwd = '***'
-    return str(u)
+    return pycompat.bytestr(u)
 
 def removeauth(u):
     '''remove all authentication information from a url string'''