Mercurial > hg
comparison mercurial/templater.py @ 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 | 2ecce24dfcd3 |
children | 8779d35c168d |
comparison
equal
deleted
inserted
replaced
32969:30d0cb279bac | 32970:11c0bb4ccc76 |
---|---|
1099 stringify = templatefilters.stringify | 1099 stringify = templatefilters.stringify |
1100 | 1100 |
1101 def _flatten(thing): | 1101 def _flatten(thing): |
1102 '''yield a single stream from a possibly nested set of iterators''' | 1102 '''yield a single stream from a possibly nested set of iterators''' |
1103 thing = templatekw.unwraphybrid(thing) | 1103 thing = templatekw.unwraphybrid(thing) |
1104 if isinstance(thing, str): | 1104 if isinstance(thing, bytes): |
1105 yield thing | 1105 yield thing |
1106 elif thing is None: | 1106 elif thing is None: |
1107 pass | 1107 pass |
1108 elif not util.safehasattr(thing, '__iter__'): | 1108 elif not util.safehasattr(thing, '__iter__'): |
1109 yield str(thing) | 1109 yield str(thing) |
1110 else: | 1110 else: |
1111 for i in thing: | 1111 for i in thing: |
1112 i = templatekw.unwraphybrid(i) | 1112 i = templatekw.unwraphybrid(i) |
1113 if isinstance(i, str): | 1113 if isinstance(i, bytes): |
1114 yield i | 1114 yield i |
1115 elif i is None: | 1115 elif i is None: |
1116 pass | 1116 pass |
1117 elif not util.safehasattr(i, '__iter__'): | 1117 elif not util.safehasattr(i, '__iter__'): |
1118 yield str(i) | 1118 yield str(i) |