This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Avoid warnings in PyModuleDef_HEAD_INIT
Type: compile error Stage: resolved
Components: Extension Modules Versions: Python 3.2
process
Status: closed Resolution: duplicate
Dependencies: Superseder: PyModuleDef_HEAD_INIT does not explicitly initialize all fields of m_base
View: 9518
Assigned To: Nosy List: BreamoreBoy, rnk, ronaldoussoren, scoder
Priority: normal Keywords: needs review, patch

Created on 2009-12-25 12:40 by ronaldoussoren, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
moduleobject-init-warnings.patch ronaldoussoren, 2009-12-25 12:40
Messages (4)
msg96881 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-12-25 12:40
When running GCC with warnings the compiler can warn about incomplete 
structure initializers. This gives spurious warnings when initializing a 
PyModuleDef structure using PyModuleDef_HEAD_INIT

The attached patchs changes PyModuleDef_HEAD_INIT to explicitly 
initialize all fields in PyModuleDef_Base.

An example warning that is silenced by this patch:

Modules/objc/test/structpointer2.m:19: warning: missing initializer
Modules/objc/test/structpointer2.m:19: warning: (near initialization for 
‘mod_module.m_base.m_init’)
msg109441 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-06 23:05
This is a miniscule patch to moduleobject.h could someone with the relevant knowledge please review it, thanks.
msg110001 - (view) Author: Reid Kleckner (rnk) (Python committer) Date: 2010-07-11 12:38
This patch looks good to me, after digging through the relevant module code.

I was confused though for a bit as to why PyModuleDef is a PyObject with a NULL type.  It turns out that import.c wants to keep them in a dictionary, so it needs to be able to cast to PyObject* and to access the refcount.  It never needs the type, though, so it's safe to leave it NULL.  I think it might be worth adding comments explaining that in this patch or another.
msg180744 - (view) Author: Stefan Behnel (scoder) * (Python committer) Date: 2013-01-27 05:36
This is a duplicate of issue 9518 (or the other way round) and should be closed as fixed in 3.2.
History
Date User Action Args
2022-04-11 14:56:55adminsetgithub: 51825
2013-01-27 10:57:19serhiy.storchakasetstatus: open -> closed
superseder: PyModuleDef_HEAD_INIT does not explicitly initialize all fields of m_base
resolution: duplicate
stage: patch review -> resolved
2013-01-27 05:36:03scodersetnosy: + scoder
messages: + msg180744
components: + Extension Modules
2010-07-11 12:39:00rnksetnosy: + rnk
messages: + msg110001
2010-07-06 23:05:36BreamoreBoysetkeywords: patch, patch, needs review
nosy: + BreamoreBoy
messages: + msg109441

2009-12-25 12:40:18ronaldoussorencreate