2009-10-25 93 views
2

我有一個使用Python加載一些腳本的C++應用程序。它調用腳本中的一些函數,並且一切正常,直到應用程序退出並調用Py_Finalize。然後它顯示以下內容:(GetName是其中一個腳本中的函數)什麼導致這個Python異常?

異常AttributeError:''模塊'對象沒有屬性'垃圾回收'中的'GetName''忽略 致命Python錯誤:意外異常期間垃圾回收

然後該應用程序崩潰。 我在Windows上使用Python 3.1。任何意見,將不勝感激。

回答

4

從文檔到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.

最有可能是__del__包含<somemodule>.GetName()一個電話,但該模塊已經被時間__del__被稱爲破壞。

相關問題