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__被称为破坏。