[PATCH 2 of 6] py3: replace str with bytes in isinstance()
Pulkit Goyal
7895pulkit at gmail.com
Tue Jun 20 23:31:28 UTC 2017
# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1497982578 -19800
# Tue Jun 20 23:46:18 2017 +0530
# Node ID 9fc4a0936f971133fb4a823e9171a4ea184bc970
# Parent c4652d1f51f2069505f88491ba37bbb1a132af98
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.
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -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)
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -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:
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -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
More information about the Mercurial-devel
mailing list