mercurial/templatefilters.py
changeset 36573 9b6b02a5b589
parent 36563 9d71bd25554b
child 36607 c6061cadb400
equal deleted inserted replaced
36572:9adfa48792a7 36573:9b6b02a5b589
   374     """Any type. Turns the value into text by converting values into
   374     """Any type. Turns the value into text by converting values into
   375     text and concatenating them.
   375     text and concatenating them.
   376     """
   376     """
   377     thing = templatekw.unwraphybrid(thing)
   377     thing = templatekw.unwraphybrid(thing)
   378     if util.safehasattr(thing, '__iter__') and not isinstance(thing, bytes):
   378     if util.safehasattr(thing, '__iter__') and not isinstance(thing, bytes):
       
   379         if isinstance(thing, str):
       
   380             # This is only reachable on Python 3 (otherwise
       
   381             # isinstance(thing, bytes) would have been true), and is
       
   382             # here to prevent infinite recursion bugs on Python 3.
       
   383             raise error.ProgrammingError(
       
   384                 'stringify got unexpected unicode string: %r' % thing)
   379         return "".join([stringify(t) for t in thing if t is not None])
   385         return "".join([stringify(t) for t in thing if t is not None])
   380     if thing is None:
   386     if thing is None:
   381         return ""
   387         return ""
   382     return pycompat.bytestr(thing)
   388     return pycompat.bytestr(thing)
   383 
   389