The session dictionary attached to a Python interpeter holds variables the user creates in the script interpreter

This can include objects that have complex state and need to be torn down intelligently (e.g. our SB* objects)

This will fail if the Python interpreter does not hold a valid thread state. So, acquire one, delete the session dictionary, and then let go of it on destruction

This fixes rdar://20960843

llvm-svn: 242745
This commit is contained in:
Enrico Granata 2015-07-21 00:38:25 +00:00
parent c7ae3e03e2
commit fbecf1ab1a
1 changed files with 8 additions and 0 deletions

View File

@ -212,6 +212,14 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interprete
ScriptInterpreterPython::~ScriptInterpreterPython ()
{
// the session dictionary may hold objects with complex state
// which means that they may need to be torn down with some level of smarts
// and that, in turn, requires a valid thread state
// force Python to procure itself such a thread state, nuke the session dictionary
// and then release it for others to use and proceed with the rest of the shutdown
auto gil_state = PyGILState_Ensure();
m_session_dict.Reset();
PyGILState_Release(gil_state);
}
void