changeset 32970:11c0bb4ccc76

py3: replace str with bytes in isinstance() We were using str because on Python 2, str were bytes but now we have to use bytes. Otherwise the if conditions fails and we have weird results from commands on Python 3.
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 20 Jun 2017 23:46:18 +0530
parents 30d0cb279bac
children accfa165736b
files mercurial/hg.py mercurial/templatekw.py mercurial/templater.py
diffstat 3 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Tue Jun 20 22:11:46 2017 +0530
+++ b/mercurial/hg.py	Tue Jun 20 23:46:18 2017 +0530
@@ -477,7 +477,7 @@
     remote's path/URL. Defaults to "identity."
     """
 
-    if isinstance(source, str):
+    if isinstance(source, bytes):
         origsource = ui.expandpath(source)
         source, branch = parseurl(origsource, branch)
         srcpeer = peer(ui, peeropts, source)
--- a/mercurial/templatekw.py	Tue Jun 20 22:11:46 2017 +0530
+++ b/mercurial/templatekw.py	Tue Jun 20 23:46:18 2017 +0530
@@ -126,7 +126,7 @@
             yield templ(noname, **mapping)
         return
     if name not in templ:
-        if isinstance(values[0], str):
+        if isinstance(values[0], bytes):
             yield separator.join(values)
         else:
             for v in values:
--- a/mercurial/templater.py	Tue Jun 20 22:11:46 2017 +0530
+++ b/mercurial/templater.py	Tue Jun 20 23:46:18 2017 +0530
@@ -1101,7 +1101,7 @@
 def _flatten(thing):
     '''yield a single stream from a possibly nested set of iterators'''
     thing = templatekw.unwraphybrid(thing)
-    if isinstance(thing, str):
+    if isinstance(thing, bytes):
         yield thing
     elif thing is None:
         pass
@@ -1110,7 +1110,7 @@
     else:
         for i in thing:
             i = templatekw.unwraphybrid(i)
-            if isinstance(i, str):
+            if isinstance(i, bytes):
                 yield i
             elif i is None:
                 pass