فهرست منبع

Provide necessary detail when failing to decode string literals

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@42482 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 15 سال پیش
والد
کامیت
04a8bbf46b
1فایلهای تغییر یافته به همراه4 افزوده شده و 1 حذف شده
  1. 4 1
      lib/python/ctypes/ctypesgencore/parser/pplexer.py

+ 4 - 1
lib/python/ctypes/ctypesgencore/parser/pplexer.py

@@ -57,7 +57,10 @@ class StringLiteral(str):
     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)
 
 # --------------------------------------------------------------------------