py3: fix join(), min(), and max() template functions over string
authorYuya Nishihara <yuya@tcha.org>
Thu, 01 Mar 2018 16:42:24 -0500
changeset 36544 a16fceb686a7
parent 36543 3e458c583d2c
child 36545 ab7f86a748e6
py3: fix join(), min(), and max() template functions over string It's silly to split a string into characters and concatenate them, but that should work and test-command-template.t has one. min() and max() had the same issue on Python 3, so fixed too.
mercurial/templater.py
--- a/mercurial/templater.py	Thu Mar 01 16:32:45 2018 -0500
+++ b/mercurial/templater.py	Thu Mar 01 16:42:24 2018 -0500
@@ -908,7 +908,7 @@
         joiner = evalstring(context, mapping, args[1])
 
     first = True
-    for x in joinset:
+    for x in pycompat.maybebytestr(joinset):
         if first:
             first = False
         else:
@@ -991,7 +991,7 @@
 
     iterable = evalfuncarg(context, mapping, args[0])
     try:
-        x = max(iterable)
+        x = max(pycompat.maybebytestr(iterable))
     except (TypeError, ValueError):
         # i18n: "max" is a keyword
         raise error.ParseError(_("max first argument should be an iterable"))
@@ -1006,7 +1006,7 @@
 
     iterable = evalfuncarg(context, mapping, args[0])
     try:
-        x = min(iterable)
+        x = min(pycompat.maybebytestr(iterable))
     except (TypeError, ValueError):
         # i18n: "min" is a keyword
         raise error.ParseError(_("min first argument should be an iterable"))