Skip to content

Commit 78ee782

Browse files
authored
feat: Add C++ binding to throw AttributeError (#3387)
* Add C++ bindings to throw AttributeError * Fix formatting bug
1 parent 076c89f commit 78ee782

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

docs/advanced/exceptions.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ at its exception handler.
5656
+--------------------------------------+--------------------------------------+
5757
| :class:`pybind11::buffer_error` | ``BufferError`` |
5858
+--------------------------------------+--------------------------------------+
59-
| :class:`pybind11::import_error` | ``import_error`` |
59+
| :class:`pybind11::import_error` | ``ImportError`` |
60+
+--------------------------------------+--------------------------------------+
61+
| :class:`pybind11::attribute_error` | ``AttributeError`` |
6062
+--------------------------------------+--------------------------------------+
6163
| Any other exception | ``RuntimeError`` |
6264
+--------------------------------------+--------------------------------------+

include/pybind11/detail/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,7 @@ PYBIND11_RUNTIME_EXCEPTION(value_error, PyExc_ValueError)
831831
PYBIND11_RUNTIME_EXCEPTION(type_error, PyExc_TypeError)
832832
PYBIND11_RUNTIME_EXCEPTION(buffer_error, PyExc_BufferError)
833833
PYBIND11_RUNTIME_EXCEPTION(import_error, PyExc_ImportError)
834+
PYBIND11_RUNTIME_EXCEPTION(attribute_error, PyExc_AttributeError)
834835
PYBIND11_RUNTIME_EXCEPTION(cast_error, PyExc_RuntimeError) /// Thrown when pybind11::cast or handle::call fail due to a type casting error
835836
PYBIND11_RUNTIME_EXCEPTION(reference_cast_error, PyExc_RuntimeError) /// Used internally
836837

0 commit comments

Comments
 (0)