From d272cee8389c33baa2cbb4f9ea62b427fa027610 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 11 Jul 2016 18:28:23 +0100 Subject: [PATCH] python: Don't generate calls with non-existent C optargs structures. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the case where we are building a Python dist (which can be distributed separately), we generated calls to non-existent optargs structures if an API was once no-optargs but had optargs added. A typical error was this (library: 1.32.5, Python sdist: 1.33.42): guestfs-py.c: In function ‘guestfs_int_py_glob_expand’: guestfs-py.c:9648:40: error: storage size of ‘optargs_s’ isn’t known struct guestfs_glob_expand_opts_argv optargs_s; This is a simple solution to this, although it has the possible disadvantage that such functions will not be bound at all. --- generator/python.ml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generator/python.ml b/generator/python.ml index 470abe7d4..31b0875df 100644 --- a/generator/python.ml +++ b/generator/python.ml @@ -253,8 +253,9 @@ put_table (char * const * const argv) List.iter ( fun { name = name; style = (ret, args, optargs as style); blocking = blocking; + c_name = c_name; c_function = c_function; c_optarg_prefix = c_optarg_prefix } -> - pr "#ifdef GUESTFS_HAVE_%s\n" (String.uppercase name); + pr "#ifdef GUESTFS_HAVE_%s\n" (String.uppercase c_name); pr "static PyObject *\n"; pr "guestfs_int_py_%s (PyObject *self, PyObject *args)\n" name; pr "{\n"; @@ -560,8 +561,8 @@ put_table (char * const * const argv) pr " { (char *) \"event_to_string\",\n"; pr " guestfs_int_py_event_to_string, METH_VARARGS, NULL },\n"; List.iter ( - fun { name = name } -> - pr "#ifdef GUESTFS_HAVE_%s\n" (String.uppercase name); + fun { name = name; c_name = c_name } -> + pr "#ifdef GUESTFS_HAVE_%s\n" (String.uppercase c_name); pr " { (char *) \"%s\", guestfs_int_py_%s, METH_VARARGS, NULL },\n" name name; pr "#endif\n"