[Greater-commits] r359 - trunk/GREAT-ER-DB/generator/GreaterAPIGenerator

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jul 6 17:14:26 CEST 2011


Author: bricks
Date: 2011-07-06 17:14:25 +0200 (Wed, 06 Jul 2011)
New Revision: 359

Modified:
   trunk/GREAT-ER-DB/generator/GreaterAPIGenerator/greatertypes.py
Log:
Check if temp is really a string
If this isn't checked it can cause a python error later which points to the wrong place
This caused my for key in dict(): issue


Modified: trunk/GREAT-ER-DB/generator/GreaterAPIGenerator/greatertypes.py
===================================================================
--- trunk/GREAT-ER-DB/generator/GreaterAPIGenerator/greatertypes.py	2011-07-06 15:12:08 UTC (rev 358)
+++ trunk/GREAT-ER-DB/generator/GreaterAPIGenerator/greatertypes.py	2011-07-06 15:14:25 UTC (rev 359)
@@ -160,6 +160,11 @@
                         "}",
                         "else",
                         "{",
+                        "    if (!PyString_Check(temp)) {",
+                        '        PyErr_Format(PyExc_TypeError, '
+                        '"s->%s must be a string or None");' % name,
+                        "        goto fail;",
+                        "    }",
                         "    s->%s = PyString_AsString(temp);" % name,
                         "}"])
                 else:



More information about the Greater-commits mailing list