What is causing this Python exception?

I have a C ++ application that uses Python to load some scripts. It calls some functions in scripts and everything works fine until the application 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 application will crash. I am using Python 3.1 on Windows. Any advice would be appreciated.

+2


source to share


1 answer


From the docs in Py_Finalize ():

Errors and caveats: destruction of modules and objects in modules in a random order; this can cause destructors (methods __del__()

) to fail when they depend on other objects (even functions) or modules. Dynamically loaded Python plugins are not unloaded. Small amounts of memory allocated by the Python interpreter may not exist (if you find a leak, please report it). The memory associated with circular references between objects is not freed. Some memory allocated to expansion modules cannot be freed. Some extensions may not work correctly if their initialization routine is called more than once; this can happen if the application calls Py_Initialize () and Py_Finalize () more than once.



Most likely a __del__

contains a call <somemodule>.GetName()

, but this module has already been destroyed by the time __del__

.

+4


source







All Articles