[PATCH 1 of 7] formatter: support json formatting of long type

Gregory Szorc gregory.szorc at gmail.com
Tue Mar 14 05:15:43 UTC 2017


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1489455089 25200
#      Mon Mar 13 18:31:29 2017 -0700
# Node ID f6f1f5efe05f4e3737dc198284f548e31a616f4b
# Parent  1c48a8278b2f015fca607dfc652823560a5ac580
formatter: support json formatting of long type

By luck, we appear to not pass any long instances into
the JSON formatter. I suspect this will change with all the
Python 3 porting work. Plus I have another series that will
convert some ints to longs that triggers this.

diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -295,7 +295,7 @@ def _jsonifyobj(v):
         return 'true'
     elif v is False:
         return 'false'
-    elif isinstance(v, (int, float)):
+    elif isinstance(v, (int, long, float)):
         return str(v)
     else:
         return '"%s"' % encoding.jsonescape(v)


More information about the Mercurial-devel mailing list