[GRASS-SVN] r43167 - grass/trunk/lib/python/ctypes/ctypesgencore

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 20 07:19:20 EDT 2010


Author: glynn
Date: 2010-08-20 11:19:20 +0000 (Fri, 20 Aug 2010)
New Revision: 43167

Modified:
   grass/trunk/lib/python/ctypes/ctypesgencore/expressions.py
Log:
Python <=2.5 compatibility: float('inf')


Modified: grass/trunk/lib/python/ctypes/ctypesgencore/expressions.py
===================================================================
--- grass/trunk/lib/python/ctypes/ctypesgencore/expressions.py	2010-08-19 16:00:35 UTC (rev 43166)
+++ grass/trunk/lib/python/ctypes/ctypesgencore/expressions.py	2010-08-20 11:19:20 UTC (rev 43167)
@@ -68,10 +68,17 @@
     def evaluate(self, context):
         return self.value
 
+    try:
+        pos_inf = float('inf')
+        neg_inf = float('-inf')
+    except ValueError:
+        pos_inf = ()
+        neg_inf = ()
+
     def py_string(self, can_be_ctype):
-        if self.value == float('inf'):
+        if self.value == ConstantExpressionNode.pos_inf:
             return "float('inf')"
-        elif self.value == float('-inf'):
+        elif self.value == ConstantExpressionNode.neg_inf:
             return "float('-inf')"
         return repr(self.value)
 
@@ -302,4 +309,4 @@
     
     def py_string(self, can_be_ctype):
         raise ValueError, "Called py_string() an unsupported expression " \
-            "node: %s" % self.message
\ No newline at end of file
+            "node: %s" % self.message



More information about the grass-commit mailing list