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.

Author christian.heimes
Recipients Padowan, amaury.forgeotdarc, christian.heimes, python-dev
Date 2013-07-11.09:57:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1373536626.74.0.462276976204.issue18426@psf.upfronthosting.co.za>
In-reply-to
Content
In theory you are right. m->md_def could be NULL, too. But in practice it's only going to happen when you have a faulty C extension. The code tries to load a dynamic module (ELF shared library, Windows DLL, ...) with _PyImport_GetDynLoadFunc() a couple of lines before PyModule_GetDef(). Any invalid file is rejected:

>>> imp.load_dynamic("os", "Lib/os.py")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: Lib/os.py: invalid ELF header

But an extra check doesn't hurt. How do you like this?

    def = PyModule_GetDef(m);
    if (def == NULL) {
        if (!PyErr_Occured()) {
            /* m->md_def == NULL */
            PyErr_BadArgument();
        }
        goto error;
    }
History
Date User Action Args
2013-07-11 09:57:06christian.heimessetrecipients: + christian.heimes, amaury.forgeotdarc, python-dev, Padowan
2013-07-11 09:57:06christian.heimessetmessageid: <1373536626.74.0.462276976204.issue18426@psf.upfronthosting.co.za>
2013-07-11 09:57:06christian.heimeslinkissue18426 messages
2013-07-11 09:57:06christian.heimescreate