__future__ import fix for older Python versions
authorStefan Behnel <scoder@users.berlios.de>
Fri, 16 May 2008 06:46:17 +0000 (08:46 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 16 May 2008 06:46:17 +0000 (08:46 +0200)
Cython/Compiler/Future.py

index 0028d13c14e4552ae4b90c0182aa2eb4dfe14eaa..854849575bffffbcb37b97ab608e6ae52e5d0189 100644 (file)
@@ -1,5 +1,11 @@
-import __future__
+def _get_feature(name):
+    import __future__
+    try:
+        return getattr(__future__, name)
+    except AttributeError:
+        # unique fake object for earlier Python versions
+        return object()
 
-unicode_literals = __future__.unicode_literals
+unicode_literals = _get_feature("unicode_literals")
 
-del __future__
+del _get_feature