Skip to content

Commit 8fbb559

Browse files
anntzerjagerman
authored andcommitted
Clarify error_already_set documentation.
1 parent 289e5d9 commit 8fbb559

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

docs/advanced/exceptions.rst

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,45 @@ exceptions:
1111

1212
.. tabularcolumns:: |p{0.5\textwidth}|p{0.45\textwidth}|
1313

14-
+--------------------------------------+------------------------------+
15-
| C++ exception type | Python exception type |
16-
+======================================+==============================+
17-
| :class:`std::exception` | ``RuntimeError`` |
18-
+--------------------------------------+------------------------------+
19-
| :class:`std::bad_alloc` | ``MemoryError`` |
20-
+--------------------------------------+------------------------------+
21-
| :class:`std::domain_error` | ``ValueError`` |
22-
+--------------------------------------+------------------------------+
23-
| :class:`std::invalid_argument` | ``ValueError`` |
24-
+--------------------------------------+------------------------------+
25-
| :class:`std::length_error` | ``ValueError`` |
26-
+--------------------------------------+------------------------------+
27-
| :class:`std::out_of_range` | ``ValueError`` |
28-
+--------------------------------------+------------------------------+
29-
| :class:`std::range_error` | ``ValueError`` |
30-
+--------------------------------------+------------------------------+
31-
| :class:`pybind11::stop_iteration` | ``StopIteration`` (used to |
32-
| | implement custom iterators) |
33-
+--------------------------------------+------------------------------+
34-
| :class:`pybind11::index_error` | ``IndexError`` (used to |
35-
| | indicate out of bounds |
36-
| | accesses in ``__getitem__``, |
37-
| | ``__setitem__``, etc.) |
38-
+--------------------------------------+------------------------------+
39-
| :class:`pybind11::value_error` | ``ValueError`` (used to |
40-
| | indicate wrong value passed |
41-
| | in ``container.remove(...)`` |
42-
+--------------------------------------+------------------------------+
43-
| :class:`pybind11::key_error` | ``KeyError`` (used to |
44-
| | indicate out of bounds |
45-
| | accesses in ``__getitem__``, |
46-
| | ``__setitem__`` in dict-like |
47-
| | objects, etc.) |
48-
+--------------------------------------+------------------------------+
49-
| :class:`pybind11::error_already_set` | Indicates that the Python |
50-
| | exception flag has already |
51-
| | been initialized |
52-
+--------------------------------------+------------------------------+
14+
+--------------------------------------+--------------------------------------+
15+
| C++ exception type | Python exception type |
16+
+======================================+======================================+
17+
| :class:`std::exception` | ``RuntimeError`` |
18+
+--------------------------------------+--------------------------------------+
19+
| :class:`std::bad_alloc` | ``MemoryError`` |
20+
+--------------------------------------+--------------------------------------+
21+
| :class:`std::domain_error` | ``ValueError`` |
22+
+--------------------------------------+--------------------------------------+
23+
| :class:`std::invalid_argument` | ``ValueError`` |
24+
+--------------------------------------+--------------------------------------+
25+
| :class:`std::length_error` | ``ValueError`` |
26+
+--------------------------------------+--------------------------------------+
27+
| :class:`std::out_of_range` | ``ValueError`` |
28+
+--------------------------------------+--------------------------------------+
29+
| :class:`std::range_error` | ``ValueError`` |
30+
+--------------------------------------+--------------------------------------+
31+
| :class:`pybind11::stop_iteration` | ``StopIteration`` (used to implement |
32+
| | custom iterators) |
33+
+--------------------------------------+--------------------------------------+
34+
| :class:`pybind11::index_error` | ``IndexError`` (used to indicate out |
35+
| | of bounds access in ``__getitem__``, |
36+
| | ``__setitem__``, etc.) |
37+
+--------------------------------------+--------------------------------------+
38+
| :class:`pybind11::value_error` | ``ValueError`` (used to indicate |
39+
| | wrong value passed in |
40+
| | ``container.remove(...)``) |
41+
+--------------------------------------+--------------------------------------+
42+
| :class:`pybind11::key_error` | ``KeyError`` (used to indicate out |
43+
| | of bounds access in ``__getitem__``, |
44+
| | ``__setitem__`` in dict-like |
45+
| | objects, etc.) |
46+
+--------------------------------------+--------------------------------------+
47+
| :class:`pybind11::error_already_set` | Indicates that the Python exception |
48+
| | flag has already been set via Python |
49+
| | API calls from C++ code; this C++ |
50+
| | exception is used to propagate such |
51+
| | a Python exception back to Python. |
52+
+--------------------------------------+--------------------------------------+
5353

5454
When a Python function invoked from C++ throws an exception, it is converted
5555
into a C++ exception of type :class:`error_already_set` whose string payload

0 commit comments

Comments
 (0)