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
This commit is contained in:
Zachary Turner
2015-11-13 01:50:19 +00:00
parent 2cab8eec74
commit a87d0ae61b
3 changed files with 66 additions and 0 deletions

View File

@@ -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()
{