Patchwork [4,of,7] py3: replace str with bytes in isinstance()

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

Comments

Pulkit Goyal - May 3, 2017, 9:59 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1492698436 -19800
#      Thu Apr 20 19:57:16 2017 +0530
# Node ID 6740e4cde2638d1cfd56bf997c2aa7e741ac12bf
# Parent  ada413b057f0052a065197295801e24d49799036
py3: replace str with bytes in isinstance()

Patch

diff -r ada413b057f0 -r 6740e4cde263 mercurial/templatefilters.py
--- a/mercurial/templatefilters.py	Thu Apr 27 09:49:57 2017 +0530
+++ b/mercurial/templatefilters.py	Thu Apr 20 19:57:16 2017 +0530
@@ -231,7 +231,7 @@ 
         return 'true'
     elif isinstance(obj, (int, long, float)):
         return pycompat.bytestr(obj)
-    elif isinstance(obj, str):
+    elif isinstance(obj, bytes):
         return '"%s"' % encoding.jsonescape(obj, paranoid=paranoid)
     elif util.safehasattr(obj, 'keys'):
         out = ['%s: %s' % (json(k), json(v))
@@ -355,7 +355,7 @@ 
     text and concatenating them.
     """
     thing = templatekw.unwraphybrid(thing)
-    if util.safehasattr(thing, '__iter__') and not isinstance(thing, str):
+    if util.safehasattr(thing, '__iter__') and not isinstance(thing, bytes):
         return "".join([stringify(t) for t in thing if t is not None])
     if thing is None:
         return ""