classification
Title: import_spam() in extending python can fail without setting the error.
Type: crash Stage:
Components: Documentation Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, jak
Priority: normal Keywords:

Created on 2009-07-09 11:31 by jak, last changed 2009-07-11 10:15 by georg.brandl. This issue is now closed.

Messages (2)
msg90325 - (view) Author: Julian Andres Klode (jak) Date: 2009-07-09 11:31
The given example function initspam fails if an 

Based on some experience with my own code, I have found out that the
function import_spam() fails when the module is not importable. In this
case, it returns 0, although it should return -1 when an error occurs.

This causes a standalone program to crash if it has a main() function like:

    Py_Initialize();
    if (import_spam() < 0) {
        Py_Finalize();
        return 1;
    }
    Py_Finalize();

The function should return -1, so we can know there is an error and are
able to handle it.
msg90409 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-07-11 10:15
Thanks, fixed in r73938.
History
Date User Action Args
2009-07-11 10:15:09georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg90409
2009-07-09 11:31:47jakcreate