[Python-Dev] Error checking in init<module> functions

Armin Rigo arigo at tunes.org
Sun Apr 24 15:10:09 CEST 2005

Hi Thomas,

On Fri, Apr 22, 2005 at 04:57:26PM +0200, Thomas Heller wrote:
> PyInit_zlib(void)
> {
>     m = Py_InitModule4("zlib", zlib_methods,
> 		       zlib_module_documentation,
> 		       (PyObject*)NULL,PYTHON_API_VERSION);

I've seen a lot of code like this where laziness is actually buginess.  If the
Py_InitModule4() fails, you get a NULL in m, and that results in a segfault in
most of the cases.


More information about the Python-Dev mailing list