the patch looks OK, but out of curiosity: do you really declare all the fields of a PyTypeObject? This structure is really designed so that newer members are left at the end; most types don't need to initialize them, C standard ensures that they will be zero.
Thanks. The code in question is a wrapper to a security-sensitive library (user-space SELinux code), hence the compilation warnings have been turned up as much as possible. The .c code in question is generated by SWIG, and that does indeed appear to be writing out full initializers for PyTypeObject instances (and the other associated structs). It appears to be just Python 3's PyModuleDef_HEAD_INIT macro that leaves fields uninitialized (hence this patch). The gory details of the SWIG-generated code can be seen at: http://userspace.selinuxproject.org/trac/browser/libselinux/src/selinuxswig_wrap.c (and the .i files in that directory) Although it's not on by default gcc will issue a "missing initializer" warning when fields aren't initialized when "-Wmissing-field-initializers" is enabled (in this case, due to the use of "-W"). This becomes an error with -Werror. Whether or not this is a useful warning isn't clear to me, but it seems to be reasonable to suppress the warning given that as-is, people who use gcc's "-W" catch-all will run into this on all Python 3 modules, and that the patch is trivial, and that this case gives no warnings when building such code against Python 2.* Hope this makes sense.
I agree that this is annoying, we get the same thing in Cython's test suite all over the place. Any foreign warning that doesn't get triggered helps in debugging your own code. And this one is easy to avoid.
keywords:patch, patchtitle: PyModuleDef_HEAD_INIT does not explicitly initial all fields of m_base -> PyModuleDef_HEAD_INIT does not explicitly initialize all fields of m_base