]> granicus.if.org Git - python/commitdiff
Issue #9928: Properly initialize the types exported by the bz2 module.
authorAntoine Pitrou <solipsis@pitrou.net>
Thu, 23 Sep 2010 19:51:39 +0000 (19:51 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Thu, 23 Sep 2010 19:51:39 +0000 (19:51 +0000)
Misc/NEWS
Modules/bz2module.c

index 514ea6d6a3785a168bd8347edc6903ceb6d60e23..243bc6fda6a0dae99e58c05e33a2c8adc055d3a9 100644 (file)
--- 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.
 
index c44d3b97f1f740d84d26e689b8492dc26af78649..3e55202bd8bae9ed25e42a36056bb47509057321 100644 (file)
@@ -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)