Matteo Cafasso
2016-Apr-01 16:02 UTC
[Libguestfs] [PATCH] python: Fix bug in code generator
EDIT: forgot to add the list to the subject, sorry for the spam. When a struct containing FChar fields is defined in generator/structs.ml, the Python code generator will generate code referencing a dirent struct instead of the correct one thus breaking at compile time. This bug was left unnoticed because the dirent struct is the only one using FChar fields. Yet it prevents any other struct from using such fields. Signed-off-by: Matteo Cafasso <noxdafox at gmail.com> --- generator/python.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/generator/python.ml b/generator/python.ml index 9663fb4..9d9dc4a 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -225,10 +225,12 @@ put_table (char * const * const argv) | name, FChar -> pr "#ifdef HAVE_PYSTRING_ASSTRING\n"; pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyString_FromStringAndSize (&dirent->%s, 1));\n" name; + pr " PyString_FromStringAndSize (&%s->%s, 1));\n" + typ name; pr "#else\n"; pr " PyDict_SetItemString (dict, \"%s\",\n" name; - pr " PyUnicode_FromStringAndSize (&dirent->%s, 1));\n" name; + pr " PyUnicode_FromStringAndSize (&%s->%s, 1));\n" + typ name; pr "#endif\n" ) cols; pr " return dict;\n"; -- 2.8.0.rc3
Maybe Matching Threads
- [PATCH] python: Fix bug in code generator
- [PATCH] python: check return value of Python APIs
- [PATCH] python: add simple wrappers for PyObject<->string functions
- [Bug #1406906] [PATCH] python: fix segmentation fault when setting non UTF-8 strings
- [PATCH v2] python: add simple wrappers for PyObject<->string functions