From: Antoine Pitrou Date: Thu, 23 Sep 2010 19:51:39 +0000 (+0000) Subject: Issue #9928: Properly initialize the types exported by the bz2 module. X-Git-Tag: v3.2a3~158 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=70c60449133919af4c598d562b85fcae66d20714;p=python Issue #9928: Properly initialize the types exported by the bz2 module. --- diff --git a/Misc/NEWS b/Misc/NEWS index 514ea6d6a3..243bc6fda6 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -62,6 +62,8 @@ Core and Builtins Library ------- +- Issue #9928: Properly initialize the types exported by the bz2 module. + - Issue #1675951: Allow GzipFile to work with unseekable file objects. Patch by Florian Festi. diff --git a/Modules/bz2module.c b/Modules/bz2module.c index c44d3b97f1..3e55202bd8 100644 --- a/Modules/bz2module.c +++ b/Modules/bz2module.c @@ -2155,9 +2155,12 @@ PyInit_bz2(void) { PyObject *m; - Py_TYPE(&BZ2File_Type) = &PyType_Type; - Py_TYPE(&BZ2Comp_Type) = &PyType_Type; - Py_TYPE(&BZ2Decomp_Type) = &PyType_Type; + if (PyType_Ready(&BZ2File_Type) < 0) + return NULL; + if (PyType_Ready(&BZ2Comp_Type) < 0) + return NULL; + if (PyType_Ready(&BZ2Decomp_Type) < 0) + return NULL; m = PyModule_Create(&bz2module); if (m == NULL)