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

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jun 4 01:22:58 EDT 2010


Author: glynn
Date: 2010-06-04 01:22:57 -0400 (Fri, 04 Jun 2010)
New Revision: 42482

Modified:
   grass/trunk/lib/python/ctypes/ctypesgencore/parser/pplexer.py
Log:
Provide necessary detail when failing to decode string literals


Modified: grass/trunk/lib/python/ctypes/ctypesgencore/parser/pplexer.py
===================================================================
--- grass/trunk/lib/python/ctypes/ctypesgencore/parser/pplexer.py	2010-06-04 04:58:35 UTC (rev 42481)
+++ grass/trunk/lib/python/ctypes/ctypesgencore/parser/pplexer.py	2010-06-04 05:22:57 UTC (rev 42482)
@@ -57,7 +57,10 @@
     def __new__(cls, value):
         assert value[0] == '"' and value[-1] == '"'
         # Unescaping probably not perfect but close enough.
-        value = value[1:-1].decode('string_escape')
+        try:
+            value = value[1:-1].decode('string_escape')
+        except ValueError, e:
+            raise ValueError("invalid \\x escape in %s" % value)
         return str.__new__(cls, value)
 
 # --------------------------------------------------------------------------



More information about the grass-commit mailing list