Patchwork [1,of,4,V4] hghave: add "absimport" feature to check "absolute_import" in __future__

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Oct. 4, 2013, 4:19 p.m.
Message ID <6b27b9c806334c88e3f0.1380903545@juju>
Download mbox | patch
Permalink /patch/2731/
State Accepted
Commit b8316878a685d27d2b5eb9f5576eb3de58b61e8e
Headers show

Comments

Katsunori FUJIWARA - Oct. 4, 2013, 4:19 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1380902542 -32400
#      Sat Oct 05 01:02:22 2013 +0900
# Node ID 6b27b9c806334c88e3f0190ed345e84dbc8a894d
# Parent  a69a77a80900eabe1257c935818d0910217e9702
hghave: add "absimport" feature to check "absolute_import" in __future__

This patch adds "absimport" feature to check whether "absolute_import"
exists in __future__, which means supporting module loading by
absolute name.

This check is needed for portability of test code using
"absolute_import", because Python earlier than 2.5 doesn't support it.
Matt Mackall - Oct. 20, 2013, 10:51 p.m.
On Sat, 2013-10-05 at 01:19 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1380902542 -32400
> #      Sat Oct 05 01:02:22 2013 +0900
> # Node ID 6b27b9c806334c88e3f0190ed345e84dbc8a894d
> # Parent  a69a77a80900eabe1257c935818d0910217e9702
> hghave: add "absimport" feature to check "absolute_import" in __future__

These are queued, thanks.

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -277,6 +277,11 @@ 
 def has_aix():
     return sys.platform.startswith("aix")
 
+def has_absimport():
+    import __future__
+    from mercurial import util
+    return util.safehasattr(__future__, "absolute_import")
+
 checks = {
     "true": (lambda: True, "yak shaving"),
     "false": (lambda: False, "nail clipper"),
@@ -318,4 +323,5 @@ 
     "windows": (has_windows, "Windows"),
     "msys": (has_msys, "Windows with MSYS"),
     "aix": (has_aix, "AIX"),
+    "absimport": (has_absimport, "absolute_import in __future__"),
 }