From a87d0ae61b42e06e0b86ac114e3613a9976d2ca0 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 13 Nov 2015 01:50:19 +0000 Subject: Fix a bug in PythonExceptionState and add unittest coverage. I forgot to reset the restore flag when calling member function `Acquire`. The newly added unittest should cover this case. llvm-svn: 253002 --- .../Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp index 4e3c8002fbf..b66f9a6b891 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp @@ -50,6 +50,7 @@ PythonExceptionState::Acquire(bool restore_on_exit) m_type.Reset(PyRefType::Owned, py_type); m_value.Reset(PyRefType::Owned, py_value); m_traceback.Reset(PyRefType::Owned, py_traceback); + m_restore_on_exit = restore_on_exit; } void @@ -77,6 +78,15 @@ PythonExceptionState::Discard() m_traceback.Reset(); } +void +PythonExceptionState::Reset() +{ + if (m_restore_on_exit) + Restore(); + else + Discard(); +} + bool PythonExceptionState::HasErrorOccurred() { -- cgit v1.2.3