mercurial/templatefilters.py
changeset 36573 9b6b02a5b589
parent 36563 9d71bd25554b
child 36607 c6061cadb400
--- a/mercurial/templatefilters.py	Fri Mar 02 00:37:55 2018 -0500
+++ b/mercurial/templatefilters.py	Fri Mar 02 09:08:11 2018 -0500
@@ -376,6 +376,12 @@
     """
     thing = templatekw.unwraphybrid(thing)
     if util.safehasattr(thing, '__iter__') and not isinstance(thing, bytes):
+        if isinstance(thing, str):
+            # This is only reachable on Python 3 (otherwise
+            # isinstance(thing, bytes) would have been true), and is
+            # here to prevent infinite recursion bugs on Python 3.
+            raise error.ProgrammingError(
+                'stringify got unexpected unicode string: %r' % thing)
         return "".join([stringify(t) for t in thing if t is not None])
     if thing is None:
         return ""