Patchwork [1,of,2,STABLE?] hghave: use a less brittle have-json check

login
register
mail settings
Submitter Augie Fackler
Date Nov. 10, 2014, 7:09 p.m.
Message ID <bf76ff2c2364a84def0a.1415646547@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/6667/
State Accepted
Headers show

Comments

Augie Fackler - Nov. 10, 2014, 7:09 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1415644045 18000
#      Mon Nov 10 13:27:25 2014 -0500
# Branch stable
# Node ID bf76ff2c2364a84def0ae2410d16b037409b5295
# Parent  da024d34b75f33b1bad8468d249c58d84a474c9e
hghave: use a less brittle have-json check

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -289,14 +289,17 @@  def has_python243():
 @check("json", "some json module available")
 def has_json():
     try:
-        if sys.version_info < (2, 7):
-            import simplejson as json
-        else:
-            import json
+        import json
         json.dumps
         return True
     except ImportError:
-        return False
+        try:
+            import simplejson as json
+            json.dumps
+            return True
+        except ImportError:
+            pass
+    return False
 
 @check("outer-repo", "outer repo")
 def has_outer_repo():