@@ -324,7 +324,7 @@ class error_already_set : public std::runtime_error {
324324 // / Constructs a new exception from the current Python error indicator, if any. The current
325325 // / Python error indicator will be cleared.
326326 error_already_set () : std::runtime_error (detail::error_string ()) {
327- PyErr_Fetch (&type .ptr (), &value .ptr (), &trace .ptr ());
327+ PyErr_Fetch (&m_type .ptr (), &m_value .ptr (), &m_trace .ptr ());
328328 }
329329
330330 error_already_set (const error_already_set &) = default ;
@@ -335,7 +335,7 @@ class error_already_set : public std::runtime_error {
335335 // / Give the currently-held error back to Python, if any. If there is currently a Python error
336336 // / already set it is cleared first. After this call, the current object no longer stores the
337337 // / error variables (but the `.what()` string is still available).
338- void restore () { PyErr_Restore (type .release ().ptr (), value .release ().ptr (), trace .release ().ptr ()); }
338+ void restore () { PyErr_Restore (m_type .release ().ptr (), m_value .release ().ptr (), m_trace .release ().ptr ()); }
339339
340340 // Does nothing; provided for backwards compatibility.
341341 PYBIND11_DEPRECATED (" Use of error_already_set.clear() is deprecated" )
@@ -344,10 +344,14 @@ class error_already_set : public std::runtime_error {
344344 // / Check if the currently trapped error type matches the given Python exception class (or a
345345 // / subclass thereof). May also be passed a tuple to search for any exception class matches in
346346 // / the given tuple.
347- bool matches (handle ex) const { return PyErr_GivenExceptionMatches (ex.ptr (), type.ptr ()); }
347+ bool matches (handle ex) const { return PyErr_GivenExceptionMatches (ex.ptr (), m_type.ptr ()); }
348+
349+ const object& type () const { return m_type; }
350+ const object& value () const { return m_value; }
351+ const object& trace () const { return m_trace; }
348352
349353private:
350- object type, value, trace ;
354+ object m_type, m_value, m_trace ;
351355};
352356
353357/* * \defgroup python_builtins _
0 commit comments