Skip to content

Commit 82e73cb

Browse files
committed
Issue python#9518: Extend the PyModuleDef_HEAD_INIT macro to explicitly
zero-initialize all fields, fixing compiler warnings seen when building extension modules with gcc with "-Wmissing-field-initializers" (implied by "-W")
1 parent 664c2d1 commit 82e73cb

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎Include/moduleobject.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ typedef struct PyModuleDef_Base {
2828
PyObject* m_copy;
2929
} PyModuleDef_Base;
3030

31-
#define PyModuleDef_HEAD_INIT {PyObject_HEAD_INIT(NULL)}
31+
#define PyModuleDef_HEAD_INIT { \
32+
PyObject_HEAD_INIT(NULL) \
33+
NULL, /* m_init */ \
34+
0, /* m_index */ \
35+
NULL, /* m_copy */ \
36+
}
3237

3338
typedef struct PyModuleDef{
3439
PyModuleDef_Base m_base;

‎Misc/NEWS‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ What's New in Python 3.2 Beta 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #9518: Extend the PyModuleDef_HEAD_INIT macro to explicitly
14+
zero-initialize all fields, fixing compiler warnings seen when building
15+
extension modules with gcc with "-Wmissing-field-initializers" (implied
16+
by "-W")
17+
1318
Library
1419
-------
1520

0 commit comments

Comments
 (0)