]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Backport of rev. 42093 by neal.norwitz]
authorAndrew M. Kuchling <amk@amk.ca>
Wed, 27 Sep 2006 19:17:32 +0000 (19:17 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Wed, 27 Sep 2006 19:17:32 +0000 (19:17 +0000)
Check return result from Py_InitModule*().  This API can fail.

Probably should be backported.

75 files changed:
Misc/NEWS
Modules/_bsddb.c
Modules/_curses_panel.c
Modules/_cursesmodule.c
Modules/_heapqmodule.c
Modules/_localemodule.c
Modules/_randommodule.c
Modules/_sre.c
Modules/_ssl.c
Modules/_testcapimodule.c
Modules/_tkinter.c
Modules/almodule.c
Modules/arraymodule.c
Modules/audioop.c
Modules/binascii.c
Modules/bsddbmodule.c
Modules/bz2module.c
Modules/cPickle.c
Modules/cStringIO.c
Modules/cdmodule.c
Modules/clmodule.c
Modules/cmathmodule.c
Modules/collectionsmodule.c
Modules/datetimemodule.c
Modules/dbmmodule.c
Modules/dlmodule.c
Modules/errnomodule.c
Modules/fcntlmodule.c
Modules/flmodule.c
Modules/fmmodule.c
Modules/fpectlmodule.c
Modules/fpetestmodule.c
Modules/gcmodule.c
Modules/gdbmmodule.c
Modules/grpmodule.c
Modules/imageop.c
Modules/imgfile.c
Modules/itertoolsmodule.c
Modules/linuxaudiodev.c
Modules/mathmodule.c
Modules/md5module.c
Modules/mmapmodule.c
Modules/nismodule.c
Modules/operator.c
Modules/ossaudiodev.c
Modules/parsermodule.c
Modules/posixmodule.c
Modules/puremodule.c
Modules/pwdmodule.c
Modules/pyexpat.c
Modules/readline.c
Modules/regexmodule.c
Modules/resource.c
Modules/rgbimgmodule.c
Modules/selectmodule.c
Modules/shamodule.c
Modules/signalmodule.c
Modules/socketmodule.c
Modules/stropmodule.c
Modules/structmodule.c
Modules/sunaudiodev.c
Modules/svmodule.c
Modules/symtablemodule.c
Modules/syslogmodule.c
Modules/termios.c
Modules/threadmodule.c
Modules/timemodule.c
Modules/xxmodule.c
PC/_subprocess.c
PC/_winreg.c
PC/msvcrtmodule.c
PC/winsound.c
Python/import.c
Python/marshal.c
Python/sysmodule.c

index aa9cb10346d52775b657c3fd1652bab5bc4da72c..b966fae786c37d87e765f252aa4d122aaf218405 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -15,6 +15,8 @@ Core and builtins
 - Overflow checking code in integer division ran afoul of new gcc
   optimizations.  Changed to be more standard-conforming.
 
+- Fix warnings reported by Klocwork's static analysis tool.
+
 - Patch #1541585: fix buffer overrun when performing repr() on
   a unicode string in a build with wide unicode (UCS-4) support.
 
index e07d44376dbd5f4aa2844e6964a47da06232a986..586d58047110658e182baabaf3c7ba7be915a8e9 100644 (file)
@@ -4846,6 +4846,8 @@ DL_EXPORT(void) init_bsddb(void)
 
     /* Create the module and add the functions */
     m = Py_InitModule(_bsddbModuleName, bsddb_methods);
+    if (m == NULL)
+       return;
 
     /* Add some symbolic constants to the module */
     d = PyModule_GetDict(m);
index 01243b837cb5068fda9bae6a250345426def476b..0acf3fdee82d436ee100136601240e22b177a1c0 100644 (file)
@@ -464,6 +464,8 @@ init_curses_panel(void)
 
     /* Create the module and add the functions */
     m = Py_InitModule("_curses_panel", PyCurses_methods);
+    if (m == NULL)
+       return;
     d = PyModule_GetDict(m);
 
     /* For exception _curses_panel.error */
index a5617b58f580b367c36483a417044c90b229f4ac..a3bff5fe039e695af1846d23f5b64521e13c2743 100644 (file)
@@ -2488,6 +2488,8 @@ init_curses(void)
 
        /* Create the module and add the functions */
        m = Py_InitModule("_curses", PyCurses_methods);
+       if (m == NULL)
+               return;
 
        /* Add some symbolic constants to the module */
        d = PyModule_GetDict(m);
index 5a78c453e19e5f378d1ce939626cc0b03fd83a0c..999647e11a100736afe15ce0309139b4cc70bb03 100644 (file)
@@ -610,6 +610,8 @@ init_heapq(void)
        PyObject *m;
 
        m = Py_InitModule3("_heapq", heapq_methods, module_doc);
+       if (m == NULL)
+               return;
        PyModule_AddObject(m, "__about__", PyString_FromString(__about__));
 }
 
index de470e0299d2b94bea7daab2aa06b24d81ccbc25..af6a615a09c65cbdaf33f20538b90573c5fc60a9 100644 (file)
@@ -715,6 +715,8 @@ init_locale(void)
 #endif
 
     m = Py_InitModule("_locale", PyLocale_Methods);
+    if (m == NULL)
+       return;
 
     d = PyModule_GetDict(m);
 
index 8fe2b2bc999fe2be9b180d4363d180d9a66f6f89..bd1c9d39b1b7d26d5e93fd89586df7961b4ef788 100644 (file)
@@ -573,6 +573,8 @@ init_random(void)
        if (PyType_Ready(&Random_Type) < 0)
                return;
        m = Py_InitModule3("_random", NULL, module_doc);
+       if (m == NULL)
+               return;
        Py_INCREF(&Random_Type);
        PyModule_AddObject(m, "Random", (PyObject *)&Random_Type);
 }
index 327f54a7e9c653f397f32b17c6cb90ed02c37277..6da6de54828d760958f6768a8024a59064268295 100644 (file)
@@ -3389,6 +3389,8 @@ PyMODINIT_FUNC init_sre(void)
         Scanner_Type.ob_type = &PyType_Type;
 
     m = Py_InitModule("_" SRE_MODULE, _functions);
+    if (m == NULL)
+       return;
     d = PyModule_GetDict(m);
 
     x = PyInt_FromLong(SRE_MAGIC);
index df36fe2de37c8ca2a7fb8cfdd0a0670addb11581..f2b9cdef48d859cbe1f85ab493f14c971ed4f235 100644 (file)
@@ -657,6 +657,8 @@ init_ssl(void)
        PySSL_Type.ob_type = &PyType_Type;
 
        m = Py_InitModule3("_ssl", PySSL_methods, module_doc);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
 
        /* Load _socket module and its C API */
index 287099b2d9065d2fef53af4d3a99bfbacc767a6d..c11c6822e903c5558095fd3720b7fe147c6c3dc1 100644 (file)
@@ -856,6 +856,8 @@ init_testcapi(void)
        Copyable_Type.ob_type = &PyType_Type;
 
        m = Py_InitModule("_testcapi", TestMethods);
+       if (m == NULL)
+               return;
 
        PyModule_AddObject(m, "UCHAR_MAX", PyInt_FromLong(UCHAR_MAX));
        PyModule_AddObject(m, "USHRT_MAX", PyInt_FromLong(USHRT_MAX));
index 7941a1174beda852c20fcd5a5f8f9af166309ed1..ab566125be08fa585dad47ec23f60a71988b44cb 100644 (file)
@@ -3093,6 +3093,8 @@ init_tkinter(void)
 #endif
 
        m = Py_InitModule("_tkinter", moduleMethods);
+       if (m == NULL)
+               return;
 
        d = PyModule_GetDict(m);
        Tkinter_TclError = PyErr_NewException("_tkinter.TclError", NULL, NULL);
index e457f86baf9fe0d5e4cc3b037f9407ca8174edef..fbeb13a630245bdc40f0f5c3486468f857159164 100644 (file)
@@ -1998,6 +1998,8 @@ inital(void)
        m = Py_InitModule4("al", al_methods,
                al_module_documentation,
                (PyObject*)NULL,PYTHON_API_VERSION);
+       if (m == NULL)
+               return;
 
        /* Add some symbolic constants to the module */
        d = PyModule_GetDict(m);
index 469c5cbcf20e86ff022d4e3fe8d05f9a68333de6..593fc48995467ca85211d9312e0fa58a6e0a31c2 100644 (file)
@@ -2096,6 +2096,8 @@ initarray(void)
        Arraytype.ob_type = &PyType_Type;
        PyArrayIter_Type.ob_type = &PyType_Type;
        m = Py_InitModule3("array", a_methods, module_doc);
+       if (m == NULL)
+               return;
 
         Py_INCREF((PyObject *)&Arraytype);
        PyModule_AddObject(m, "ArrayType", (PyObject *)&Arraytype);
index 023d22b238e28a94eeaaa5e338ed12eeb625416c..72b58ee14923a839d70e6dfd4e93f2156d12fa6f 100644 (file)
@@ -1376,6 +1376,8 @@ initaudioop(void)
 {
        PyObject *m, *d;
        m = Py_InitModule("audioop", audioop_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
        AudioopError = PyErr_NewException("audioop.error", NULL, NULL);
        if (AudioopError != NULL)
index 95b5050a3626086e147be2a96ee83533577d8a97..2a528d078c36637bf1a522c18ed8befe8d12cda3 100644 (file)
@@ -1334,6 +1334,8 @@ initbinascii(void)
 
        /* Create the module and add the functions */
        m = Py_InitModule("binascii", binascii_module_methods);
+       if (m == NULL)
+               return;
 
        d = PyModule_GetDict(m);
        x = PyString_FromString(doc_binascii);
index ac8c44395f7ebe197baece010d349603e49b6126..6bdffde7b2a3b55ddee561c3d96a43c7dfc8a6c8 100644 (file)
@@ -849,6 +849,8 @@ initbsddb185(void) {
 
        Bsddbtype.ob_type = &PyType_Type;
        m = Py_InitModule("bsddb185", bsddbmodule_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
        BsddbError = PyErr_NewException("bsddb.error", NULL, NULL);
        if (BsddbError != NULL)
index 8d9eaf40a9c6fe171b27db2e7fa5330b363e8d9a..272b05f9b36df957637cadec8b14336a6d9e8d3c 100644 (file)
@@ -2197,6 +2197,8 @@ initbz2(void)
        BZ2Decomp_Type.ob_type = &PyType_Type;
 
        m = Py_InitModule3("bz2", bz2_methods, bz2__doc__);
+       if (m == NULL)
+               return;
 
        PyModule_AddObject(m, "__author__", PyString_FromString(__author__));
 
index 6465139f09b05134bdaee608f65f475b3bb83c9f..c672d1f2d7616820ae2aaf314d15bc8077d21b33 100644 (file)
@@ -5741,6 +5741,8 @@ initcPickle(void)
        m = Py_InitModule4("cPickle", cPickle_methods,
                           cPickle_module_documentation,
                           (PyObject*)NULL,PYTHON_API_VERSION);
+       if (m == NULL)
+               return;
 
        /* Add some symbolic constants to the module */
        d = PyModule_GetDict(m);
index 81b9ac89e95b243f12ed9a316ae9aa1db5550a0a..cbc632b6fbf2c06d0d1b1c1f4a1e822ef25a28c2 100644 (file)
@@ -718,6 +718,7 @@ initcStringIO(void) {
   m = Py_InitModule4("cStringIO", IO_methods,
                     cStringIO_module_documentation,
                     (PyObject*)NULL,PYTHON_API_VERSION);
+  if (m == NULL) return;
 
   /* Add some symbolic constants to the module */
   d = PyModule_GetDict(m);
index 25add3e1b61337e9d1fa4f13100e5b1a3237ce18..f8efd395a19af167795d5749dfdbc2a8d3805798 100644 (file)
@@ -760,6 +760,8 @@ initcd(void)
        PyObject *m, *d;
 
        m = Py_InitModule("cd", CD_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
 
        CdError = PyErr_NewException("cd.error", NULL, NULL);
index 70e8f8e7d9a68b04285b90223e326da820c4dc1f..a535e031f530ae92f73445918d73e65386310658 100644 (file)
@@ -963,6 +963,8 @@ initcl(void)
        PyObject *m, *d, *x;
 
        m = Py_InitModule("cl", cl_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
 
        ClError = PyErr_NewException("cl.error", NULL, NULL);
index 78b9dd5f8fad55ec2122e3239bd56fdbcd3547f9..ec48ce8d7254017eac2f3207cba8aaf8c8092a96 100644 (file)
@@ -417,6 +417,8 @@ initcmath(void)
        PyObject *m;
 
        m = Py_InitModule3("cmath", cmath_methods, module_doc);
+       if (m == NULL)
+               return;
 
        PyModule_AddObject(m, "pi",
                            PyFloat_FromDouble(atan(1.0) * 4.0));
index 5af568d269b709c0dd9dd82edd46e319ddfd8599..1cceb4f58787d0d80c33a41db66bd6ff1c089588 100644 (file)
@@ -1036,6 +1036,8 @@ initcollections(void)
        PyObject *m;
 
        m = Py_InitModule3("collections", NULL, module_doc);
+       if (m == NULL)
+               return;
 
        if (PyType_Ready(&deque_type) < 0)
                return;
index e5aa73eb2579793a17557d33fb635d6bd33f41b2..6ef674046128c6ba289814623f74e909e472a68f 100644 (file)
@@ -4581,6 +4581,8 @@ initdatetime(void)
 
        m = Py_InitModule3("datetime", module_methods,
                           "Fast implementation of the datetime type.");
+       if (m == NULL)
+               return;
 
        if (PyType_Ready(&PyDateTime_DateType) < 0)
                return;
index 40d06fc26803463d9a1d1aa67b6867715adec060..cc963a2dfd87e4492adc0e070470c9d794d4267a 100644 (file)
@@ -359,6 +359,8 @@ initdbm(void) {
 
        Dbmtype.ob_type = &PyType_Type;
        m = Py_InitModule("dbm", dbmmodule_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
        if (DbmError == NULL)
                DbmError = PyErr_NewException("dbm.error", NULL, NULL);
index 927f4c0ac8287e77540c0a1068da4f1fff2353d3..09556814f2dc779e7e397ca1745416c7de0f1847 100644 (file)
@@ -219,6 +219,8 @@ initdl(void)
 
        /* Create the module and add the functions */
        m = Py_InitModule("dl", dl_methods);
+       if (m == NULL)
+               return;
 
        /* Add some symbolic constants to the module */
        d = PyModule_GetDict(m);
index e9c0990c28e06d388c3250aace90ff4de08bb291..696d396b07ad8dcae16a9de979e339eee8963e1e 100644 (file)
@@ -57,6 +57,8 @@ initerrno(void)
 {
        PyObject *m, *d, *de;
        m = Py_InitModule3("errno", errno_methods, errno__doc__);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
        de = PyDict_New();
        if (!d || !de || PyDict_SetItemString(d, "errorcode", de) < 0)
index 6fa42f8199823742b37676670ec9f7b723df135d..0c02ee62ac8a74a6bf13043cf6dfbc40a4be195a 100644 (file)
@@ -598,6 +598,8 @@ initfcntl(void)
 
        /* Create the module and add the functions and documentation */
        m = Py_InitModule3("fcntl", fcntl_methods, module_doc);
+       if (m == NULL)
+               return;
 
        /* Add some symbolic constants to the module */
        d = PyModule_GetDict(m);
index 1ae2dc85bbd260b4d24f806792a371bac2530dc1..aa0d04e4059b83c9a95394200b3af9f4ff8ed9c0 100644 (file)
@@ -2130,6 +2130,8 @@ PyMODINIT_FUNC
 initfl(void)
 {
        Py_InitModule("fl", forms_methods);
+       if (m == NULL)
+               return;
        foreground();
        fl_init();
 }
index 78a58772c2ac0f7bcba411ee4dfdad98ff96610c..01753909111262070854850af980364038b44758 100644 (file)
@@ -258,5 +258,7 @@ void
 initfm(void)
 {
        Py_InitModule("fm", fm_methods);
+       if (m == NULL)
+               return;
        fminit();
 }
index 241c1c2620fd0f44e7953d3caa8cdbc83c935a91..c6d4f77c2312566b76f06d417b8da60ebf99f36d 100644 (file)
@@ -265,6 +265,8 @@ PyMODINIT_FUNC initfpectl(void)
 {
     PyObject *m, *d;
     m = Py_InitModule("fpectl", fpectl_methods);
+    if (m == NULL)
+       return;
     d = PyModule_GetDict(m);
     fpe_error = PyErr_NewException("fpectl.error", NULL, NULL);
     if (fpe_error != NULL)
index aa14dd82a6b294819521cf530cecb1335c4b118e..22e95dbaef1f37d197b1c5746b16bad6051b7b28 100644 (file)
@@ -177,6 +177,8 @@ PyMODINIT_FUNC initfpetest(void)
     PyObject *m, *d;
 
     m = Py_InitModule("fpetest", fpetest_methods);
+    if (m == NULL)
+       return;
     d = PyModule_GetDict(m);
     fpe_error = PyErr_NewException("fpetest.error", NULL, NULL);
     if (fpe_error != NULL)
index 5366209c9a17e434486698ed0ed1f35c9b70ffaa..e30e22f068df36f57f8019ea0475b748bcd69cf7 100644 (file)
@@ -1161,6 +1161,8 @@ initgc(void)
                              gc__doc__,
                              NULL,
                              PYTHON_API_VERSION);
+       if (m == NULL)
+               return;
 
        if (garbage == NULL) {
                garbage = PyList_New(0);
index 03e664d6bc30cb60dea16bb93f6f3b46b6f89802..6045743df3d882466db7ce474080f78a42f1daad 100644 (file)
@@ -512,6 +512,8 @@ initgdbm(void) {
     m = Py_InitModule4("gdbm", dbmmodule_methods,
                        gdbmmodule__doc__, (PyObject *)NULL,
                        PYTHON_API_VERSION);
+    if (m == NULL)
+       return;
     d = PyModule_GetDict(m);
     DbmError = PyErr_NewException("gdbm.error", NULL, NULL);
     if (DbmError != NULL) {
index 5f33fe972fc8f33213d7132296209f85d04e2a01..de849c98bd5a2506f52876c1fc237be438cb11b7 100644 (file)
@@ -171,6 +171,8 @@ initgrp(void)
 {
     PyObject *m, *d;
     m = Py_InitModule3("grp", grp_methods, grp__doc__);
+    if (m == NULL)
+        return;
     d = PyModule_GetDict(m);
     PyStructSequence_InitType(&StructGrpType, &struct_group_type_desc);
     PyDict_SetItemString(d, "struct_group", (PyObject *) &StructGrpType);
index 5b87898bbbfd686e29fdf1e763f5769e84105e2e..92f805a83b62f338d39019bf5489ee1a3ceccb58 100644 (file)
@@ -776,6 +776,8 @@ initimageop(void)
 {
        PyObject *m;
        m = Py_InitModule("imageop", imageop_methods);
+       if (m == NULL)
+               return;
        ImageopDict = PyModule_GetDict(m);
        ImageopError = PyErr_NewException("imageop.error", NULL, NULL);
        if (ImageopError != NULL)
index f9fa25bc4ebbc78098229add6c8c819b8e34495e..bb85a78d5c295d761191757b8c202a835933ffb6 100644 (file)
@@ -492,6 +492,8 @@ initimgfile(void)
 {
        PyObject *m, *d;
        m = Py_InitModule("imgfile", imgfile_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
        ImgfileError = PyErr_NewException("imgfile.error", NULL, NULL);
        if (ImgfileError != NULL)
index 3d5e8a2075bb59623a0b713fc80959de3d990a50..39af2ea931ed304aa4088ad87a351f310c0681db 100644 (file)
@@ -2454,6 +2454,8 @@ inititertools(void)
 
        teedataobject_type.ob_type = &PyType_Type;
        m = Py_InitModule3("itertools", module_methods, module_doc);
+       if (m == NULL)
+               return;
 
        for (i=0 ; typelist[i] != NULL ; i++) {
                if (PyType_Ready(typelist[i]) < 0)
index 5aac51a6d923e689702b464c0900bf27c0efdf7a..7718c3be2c1dedad8b3db68bce3ccd24a3fcce89 100644 (file)
@@ -491,6 +491,8 @@ initlinuxaudiodev(void)
     PyObject *m;
   
     m = Py_InitModule("linuxaudiodev", linuxaudiodev_methods);
+    if (m == NULL)
+       return;
 
     LinuxAudioError = PyErr_NewException("linuxaudiodev.error", NULL, NULL);
     if (LinuxAudioError)
index 260511400ecf38b6f74d8e34a25a40cec1777213..4aa1731b63289e4afbc4edccd1dfb5632a9212e3 100644 (file)
@@ -355,6 +355,8 @@ initmath(void)
        PyObject *m, *d, *v;
 
        m = Py_InitModule3("math", math_methods, module_doc);
+       if (m == NULL)
+               goto finally;
        d = PyModule_GetDict(m);
 
         if (!(v = PyFloat_FromDouble(atan(1.0) * 4.0)))
index 65b83a713bce100f86686e6a83ae6ba4197b43ae..2e2677f70aa5e80ee26cf5aa4c6059ff793d36be 100644 (file)
@@ -261,6 +261,8 @@ initmd5(void)
 
         MD5type.ob_type = &PyType_Type;
        m = Py_InitModule3("md5", md5_functions, module_doc);
+       if (m == NULL)
+           return;
        d = PyModule_GetDict(m);
        PyDict_SetItemString(d, "MD5Type", (PyObject *)&MD5type);
        PyModule_AddIntConstant(m, "digest_size", 16);
index 8dcbe865f332e89bf5af16ee0e8d9e0e0c16fe87..ac647bfadb18fce2342c4aac95992549d0a12983 100644 (file)
@@ -1093,6 +1093,8 @@ PyMODINIT_FUNC
        mmap_object_type.ob_type = &PyType_Type;
 
        module = Py_InitModule ("mmap", mmap_functions);
+       if (module == NULL)
+               return;
        dict = PyModule_GetDict (module);
        mmap_module_error = PyExc_EnvironmentError;
        Py_INCREF(mmap_module_error);
index 2494adbbedad622d2ca7c5f96fc1cbfa553c8025..207f7b8e7e52cb804c5f0318ddad8596751d816f 100644 (file)
@@ -379,6 +379,8 @@ initnis (void)
 {
        PyObject *m, *d;
        m = Py_InitModule("nis", nis_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
        NisError = PyErr_NewException("nis.error", NULL, NULL);
        if (NisError != NULL)
index df19f6be631560940b4b702fa29087e3b2e9985b..86f02356abdd72a51e8bae84cfb4c74bbb08abc2 100644 (file)
@@ -480,6 +480,8 @@ initoperator(void)
        /* Create the module and add the functions */
         m = Py_InitModule4("operator", operator_methods, operator_doc,
                       (PyObject*)NULL, PYTHON_API_VERSION);
+       if (m == NULL)
+               return;
 
        if (PyType_Ready(&itemgetter_type) < 0)
                return;
index 11592353ce52417c38922deef61524a52a979707..35e67635bc6127c8570e0779f3d8845a87d85cdb 100644 (file)
@@ -943,6 +943,8 @@ initossaudiodev(void)
     PyObject *m;
 
     m = Py_InitModule("ossaudiodev", ossaudiodev_methods);
+    if (m == NULL)
+       return;
 
     OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError",
                                       NULL, NULL);
index eb23b585724f611e35a625f192bb6dfe4bd5a672..6c7a07df09b980671b49dfa3e24a59eacdedda18 100644 (file)
@@ -3106,6 +3106,8 @@ initparser(void)
 
     PyST_Type.ob_type = &PyType_Type;
     module = Py_InitModule("parser", parser_functions);
+    if (module == NULL)
+       return;
 
     if (parser_error == 0)
         parser_error = PyErr_NewException("parser.ParserError", NULL, NULL);
index f9718f3856d65e54f02c5ff63bc697cc027ca0c2..8906e2b478c8dc4780409d6ca07bd8444f5023a1 100644 (file)
@@ -7935,6 +7935,8 @@ INITFUNC(void)
        m = Py_InitModule3(MODNAME,
                           posix_methods,
                           posix__doc__);
+       if (m == NULL)
+               return;
 
        /* Initialize environ dictionary */
        v = convertenviron();
index 43c64414cb1cfc7335b9f517cae02b8b98d05cad..95f4bdecdbc4d5b676d47cddb71e6d6f4d5396d6 100644 (file)
@@ -952,6 +952,8 @@ initpure()
        PyObject *m, *d;
 
        m = Py_InitModule("pure", pure_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
 
         /* this is bogus because we should be able to find this information
index f418e43c9a858c9f01532f6903f9e5e010a4f9b9..9e7b864b75a045cbccc69ed76160cb04dac9882c 100644 (file)
@@ -183,6 +183,8 @@ initpwd(void)
 {
        PyObject *m;
        m = Py_InitModule3("pwd", pwd_methods, pwd__doc__);
+       if (m == NULL)
+               return;
 
        PyStructSequence_InitType(&StructPwdType, &struct_pwd_type_desc);
        Py_INCREF((PyObject *) &StructPwdType);
index 2317d2ec01321b118a561546756eb208c8e72b45..9160bf2ee240c03cca4c4beabba58319aadf3124 100644 (file)
@@ -1853,6 +1853,8 @@ MODULE_INITFUNC(void)
     /* Create the module and add the functions */
     m = Py_InitModule3(MODULE_NAME, pyexpat_methods,
                        pyexpat_module_documentation);
+    if (m == NULL)
+       return;
 
     /* Add some symbolic constants to the module */
     if (ErrorObject == NULL) {
index 43ac6281307fcf006e1d8e5c3d95b0a1135013bb..a01935ba9698295958fa57cc28c72e877ecc9aab 100644 (file)
@@ -927,6 +927,8 @@ initreadline(void)
 
        m = Py_InitModule4("readline", readline_methods, doc_module,
                           (PyObject *)NULL, PYTHON_API_VERSION);
+       if (m == NULL)
+               return;
 
        PyOS_ReadlineFunctionPointer = call_readline;
        setup_readline();
index f75e9b20ef7aae83fc1dd7e72c9c3db4bf7ea2db..2fb41982077dde2d5bae58de6cff7908d0086e7d 100644 (file)
@@ -652,6 +652,8 @@ initregex(void)
        Regextype.ob_type = &PyType_Type;
 
        m = Py_InitModule("regex", regex_global_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
 
        if (PyErr_Warn(PyExc_DeprecationWarning,
index c5bec79043d25d3a7955e78a7e7f51cd8f1ed73f..7cbd2c94b490c50561fc9db2d18986c2225115a8 100644 (file)
@@ -234,6 +234,8 @@ initresource(void)
 
        /* Create the module and add the functions */
        m = Py_InitModule("resource", resource_methods);
+       if (m == NULL)
+               return;
 
        /* Add some symbolic constants to the module */
        if (ResourceError == NULL) {
index 904c64b642ec2fdec4e0ad12bc36ab58e8f82f37..8c70d95e74ff8d82ab3590652369a05f6618646f 100644 (file)
@@ -756,6 +756,8 @@ initrgbimg(void)
 {
        PyObject *m, *d;
        m = Py_InitModule("rgbimg", rgbimg_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
        ImgfileError = PyErr_NewException("rgbimg.error", NULL, NULL);
        if (ImgfileError != NULL)
index ed2ea8197c5a934040c2747b6e77d2b99c3d6870..53c68c1a55983959c6019098ce132537153a6002 100644 (file)
@@ -662,6 +662,8 @@ initselect(void)
 {
        PyObject *m;
        m = Py_InitModule3("select", select_methods, module_doc);
+       if (m == NULL)
+               return;
 
        SelectError = PyErr_NewException("select.error", NULL, NULL);
        Py_INCREF(SelectError);
index 1b3b76a09fda1b424e42089edabbb3bb547238b0..fa619298832882412c61ad534eaa3f501ea46413 100644 (file)
@@ -532,6 +532,8 @@ initsha(void)
 
     SHAtype.ob_type = &PyType_Type;
     m = Py_InitModule("sha", SHA_functions);
+    if (m == NULL)
+       return;
 
     /* Add some symbolic constants to the module */
     insint("blocksize", 1);  /* For future use, in case some hash
index bec27293e9e6bc9ce5f64d00681a0162a8a8cec9..a729604a316bf4cb27376d880e54b12e32518c56 100644 (file)
@@ -317,6 +317,8 @@ initsignal(void)
 
        /* Create the module and add the functions */
        m = Py_InitModule3("signal", signal_methods, module_doc);
+       if (m == NULL)
+               return;
 
        /* Add some symbolic constants to the module */
        d = PyModule_GetDict(m);
index 4f46ba6e7c82b0b067b919e48ab2339c1d1f181d..a63c882740f902478f236c29e99629c8b1c3d488 100644 (file)
@@ -3872,6 +3872,8 @@ init_socket(void)
        m = Py_InitModule3(PySocket_MODULE_NAME,
                           socket_methods,
                           socket_doc);
+       if (m == NULL)
+               return;
 
        socket_error = PyErr_NewException("socket.error", NULL, NULL);
        if (socket_error == NULL)
index ce19a053a09856dcdc2fae033f8cc7e27b1957c2..30b86d4624b00599626d980abd78f8f408ed705b 100644 (file)
@@ -1210,6 +1210,8 @@ initstrop(void)
        int c, n;
        m = Py_InitModule4("strop", strop_methods, strop_module__doc__,
                           (PyObject*)NULL, PYTHON_API_VERSION);
+       if (m == NULL)
+               return;
 
        /* Create 'whitespace' object */
        n = 0;
index 137b8988e041c7ad1db5ce67efae0cbfabf392f1..f07f21a30cc8c07ef4cddefc15ab6ed55b0c333d 100644 (file)
@@ -1278,6 +1278,8 @@ initstruct(void)
        /* Create the module and add the functions */
        m = Py_InitModule4("struct", struct_methods, struct__doc__,
                           (PyObject*)NULL, PYTHON_API_VERSION);
+       if (m == NULL)
+               return;
 
        /* Add some symbolic constants to the module */
        if (StructError == NULL) {
index 3269c761d64f17a8e18899c354404aa8864d24a9..802184d0d6fe8789bac06c1041495a0c99d4a2b5 100644 (file)
@@ -456,6 +456,8 @@ initsunaudiodev(void)
        PyObject *m, *d;
 
        m = Py_InitModule("sunaudiodev", sunaudiodev_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
        SunAudioError = PyErr_NewException("sunaudiodev.error", NULL, NULL);
        if (SunAudioError)
index 9bd79686c4ecac59b9a83995c9c1bb48e32c4682..fb58f19cc3517b09fd9db7b1faa3666c25223e8d 100644 (file)
@@ -956,6 +956,8 @@ initsv(void)
        PyObject *m, *d;
 
        m = Py_InitModule("sv", sv_methods);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
 
        SvError = PyErr_NewException("sv.error", NULL, NULL);
index 909a404fdc5fa55d2d9fb553f2adadf85722f225..53999a76800049ca49ce95fc408073982cecd733 100644 (file)
@@ -51,6 +51,8 @@ init_symtable(void)
        PyObject *m;
 
        m = Py_InitModule("_symtable", symtable_methods);
+       if (m == NULL)
+               return;
        PyModule_AddIntConstant(m, "USE", USE);
        PyModule_AddIntConstant(m, "DEF_GLOBAL", DEF_GLOBAL);
        PyModule_AddIntConstant(m, "DEF_LOCAL", DEF_LOCAL);
index 1f2b874fdbe0f92db408a750fb0667725b6fe741..dd35923139a99228736c755af1707c8cff79a834 100644 (file)
@@ -163,6 +163,8 @@ initsyslog(void)
 
        /* Create the module and add the functions */
        m = Py_InitModule("syslog", syslog_methods);
+       if (m == NULL)
+               return;
 
        /* Add some symbolic constants to the module */
 
index a1d14a18b845b0ef8be655c6675e5472cc867413..c53566c12b70524941dea6ec1fe7a145c7703573 100644 (file)
@@ -910,6 +910,8 @@ PyInit_termios(void)
 
        m = Py_InitModule4("termios", termios_methods, termios__doc__,
                            (PyObject *)NULL, PYTHON_API_VERSION);
+       if (m == NULL)
+               return;
 
        if (TermiosError == NULL) {
                TermiosError = PyErr_NewException("termios.error", NULL, NULL);
index 052262cda22d4480f2d3625bc547820375fff0a1..831da13c53f00e81cd5c1cf40c0119994608b46b 100644 (file)
@@ -650,6 +650,8 @@ initthread(void)
 
        /* Create the module and add the functions */
        m = Py_InitModule3("thread", thread_methods, thread_doc);
+       if (m == NULL)
+               return;
 
        /* Add a symbolic constant */
        d = PyModule_GetDict(m);
index 2cd9a571f3dc1eab35d69fc75ddd495abd460585..ba93957b8856c2b86b0f6d8630c2861c178a211b 100644 (file)
@@ -785,6 +785,8 @@ inittime(void)
        PyObject *m;
        char *p;
        m = Py_InitModule3("time", time_methods, module_doc);
+       if (m == NULL)
+               return;
 
        /* Accept 2-digit dates unless PYTHONY2K is set and non-empty */
        p = Py_GETENV("PYTHONY2K");
index 5f75b6cf8f9de6d6064b67f4ac9fd5ff8d10ffd0..ea66eefa0a6829f0755021b76c7e2031289e5eda 100644 (file)
@@ -352,6 +352,8 @@ initxx(void)
 
        /* Create the module and add the functions */
        m = Py_InitModule3("xx", xx_methods, module_doc);
+       if (m == NULL)
+               return;
 
        /* Add some symbolic constants to the module */
        if (ErrorObject == NULL) {
index ddaef5ca341388486cf27fc15c6cdcb7fb7308da..3d0a27d0bb181fe0a84a0e240ed78f5f4f3553b5 100644 (file)
@@ -530,6 +530,8 @@ init_subprocess()
        sp_handle_as_number.nb_int = (unaryfunc) sp_handle_as_int;
 
        m = Py_InitModule("_subprocess", sp_functions);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
 
        /* constants */
index a20b09a4ee038ce0ce426e5ce100d8cd02ffbd3e..09622be3ceb0d24ba1edc7acee246f7e4dfc6c90 100644 (file)
@@ -1459,6 +1459,8 @@ PyMODINIT_FUNC init_winreg(void)
 {
        PyObject *m, *d;
        m = Py_InitModule3("_winreg", winreg_methods, module_doc);
+       if (m == NULL)
+               return;
        d = PyModule_GetDict(m);
        PyHKEY_Type.ob_type = &PyType_Type;
        PyHKEY_Type.tp_doc = PyHKEY_doc;
index 84cf0c132ea344e40e7d2d6c0676633f1e37106f..4453023a6a8acd95d26117a78e006db06511c772 100755 (executable)
@@ -221,6 +221,8 @@ PyMODINIT_FUNC
 initmsvcrt(void)
 {
        PyObject *m = Py_InitModule("msvcrt", msvcrt_functions);
+       if (m == NULL)
+               return;
        PyObject *d = PyModule_GetDict(m);
 
        /* constants for the locking() function's mode argument */
index c6f3a534fa1f571bcd97f22cfdd464c4bb3d2dd9..0d22fa15f752f8ddc60c316d3570c1da6f23e81b 100644 (file)
@@ -218,6 +218,8 @@ initwinsound(void)
        PyObject *module = Py_InitModule3("winsound",
                                          sound_methods,
                                          sound_module_doc);
+       if (module == NULL)
+               return;
        PyObject *dict = PyModule_GetDict(module);
 
        ADD_DEFINE(SND_ASYNC);
index ee7c59300ee40c990550b4b3d81428bcbe95e320..5033819d8c454f3248f957683958ce37b823a87d 100644 (file)
@@ -2822,6 +2822,8 @@ initimp(void)
 
        m = Py_InitModule4("imp", imp_methods, doc_imp,
                           NULL, PYTHON_API_VERSION);
+       if (m == NULL)
+               goto failure;
        d = PyModule_GetDict(m);
 
        if (setint(d, "SEARCH_ERROR", SEARCH_ERROR) < 0) goto failure;
index 0ab0597d321bbb59b62bdc1e5b81a1bc93f82ce9..df88bcb2c7948d34470afe20cc085dce5adf50b0 100644 (file)
@@ -928,5 +928,7 @@ PyMODINIT_FUNC
 PyMarshal_Init(void)
 {
        PyObject *mod = Py_InitModule("marshal", marshal_methods);
+       if (mod == NULL)
+               return;
        PyModule_AddIntConstant(mod, "version", Py_MARSHAL_VERSION);
 }
index b51fa86a760cd46bdb2b33973afa7e6bf9ef85f3..d48194b3b888f66137c2231db8f645737db48377 100644 (file)
@@ -944,6 +944,8 @@ _PySys_Init(void)
 #endif
 
        m = Py_InitModule3("sys", sys_methods, sys_doc);
+       if (m == NULL)
+               return NULL;
        sysdict = PyModule_GetDict(m);
 
        {