[BUGFIX] Fixing pybind11::error_already_set.matches to also work with exception subclasses (#1715)

* Fixing order of arguments in call to PyErr_GivenExceptionMatches in pybind11::error_already_set.matches

* Added tests on error_already_set::matches fix for exception base classes
This commit is contained in:
Yannick Jadoul
2019-05-12 23:35:49 +02:00
committed by Wenzel Jakob
parent a0b8f70df4
commit 97784dad3e
3 changed files with 33 additions and 3 deletions

View File

@@ -344,7 +344,7 @@ public:
/// Check if the currently trapped error type matches the given Python exception class (or a
/// subclass thereof). May also be passed a tuple to search for any exception class matches in
/// the given tuple.
bool matches(handle ex) const { return PyErr_GivenExceptionMatches(ex.ptr(), m_type.ptr()); }
bool matches(handle exc) const { return PyErr_GivenExceptionMatches(m_type.ptr(), exc.ptr()); }
const object& type() const { return m_type; }
const object& value() const { return m_value; }