formatter: convert float value to json
authorYuya Nishihara <yuya@tcha.org>
Wed, 17 Sep 2014 22:21:01 +0900
changeset 22476 a0829ec34dbd
parent 22475 17eeda31e52b
child 22477 3c8ae79eacb0
formatter: convert float value to json It will be used to encode ctx.date().
mercurial/formatter.py
--- a/mercurial/formatter.py	Wed Sep 17 21:30:22 2014 +0900
+++ b/mercurial/formatter.py	Wed Sep 17 22:21:01 2014 +0900
@@ -91,8 +91,8 @@
 def _jsonifyobj(v):
     if isinstance(v, tuple):
         return '[' + ', '.join(_jsonifyobj(e) for e in v) + ']'
-    elif isinstance(v, int):
-        return '%d' % v
+    elif isinstance(v, (int, float)):
+        return str(v)
     else:
         return '"%s"' % encoding.jsonescape(v)