views:

85

answers:

1

I have a C++ app that uses Python to load some scripts. It calls some functions in the scripts, and everything works fine until the app exits and calls Py_Finalize. Then it displays the following: (GetName is a function in one of the scripts)

Exception AttributeError: "'module' object has no attribute 'GetName'" in 'garbage collection' ignored Fatal Python error: unexpected exception during garbage collection

Then the app crashes. I'm using Python 3.1 on Windows. Any advice would be appreciated.

+3  A: 

From the docs to Py_Finalize():

Bugs and caveats: The destruction of modules and objects in modules is done in random order; this may cause destructors (__del__() methods) to fail when they depend on other objects (even functions) or modules. Dynamically loaded extension modules loaded by Python are not unloaded. Small amounts of memory allocated by the Python interpreter may not be freed (if you find a leak, please report it). Memory tied up in circular references between objects is not freed. Some memory allocated by extension modules may not be freed. Some extensions may not work properly if their initialization routine is called more than once; this can happen if an application calls Py_Initialize() and Py_Finalize() more than once.

Most likely a __del__ contains a call to <somemodule>.GetName(), but that module has already been destroyed by the time __del__ is called.

Paul Du Bois