Skip to content

Commit 5498fe8

Browse files
committed
Make documentation more concise
1 parent 8eff997 commit 5498fe8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

docs/advanced/exceptions.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Registering custom translators
6767

6868
If the default exception conversion policy described above is insufficient,
6969
pybind11 also provides support for registering custom exception translators.
70+
7071
Similar to pybind11 classes, exception translators can be local to the module
7172
they are defined in or global to the entire python session. To register a simple
7273
exception conversion that translates a C++ exception into a new Python exception
@@ -93,7 +94,6 @@ parameter, a `handle`:
9394
.. code-block:: cpp
9495
9596
py::register_exception<CppExp>(module, "PyExp", PyExc_RuntimeError);
96-
py::register_local_exception<CppExp>(module, "PyExp", PyExc_RuntimeError);
9797
9898
Then `PyExp` can be caught both as `PyExp` and `RuntimeError`.
9999

@@ -170,10 +170,9 @@ section.
170170
Local vs Global Exception Translators
171171
=====================================
172172

173-
Similar to how the ``py::module_local`` flag allows uesrs to limit a bound class
174-
to a single compiled module to prevent name collisions. When a global exception
175-
translator is registered, it will be applied across all modules in the reverse
176-
order of registration. This can create behavior where the order of module import
173+
When a global exception translator is registered, it will be applied across all
174+
modules in the reverse order of registration. When there are multiple pybind11
175+
modules being loaded, this can create behavior where the order of module import
177176
influences how exceptions are translated.
178177

179178
If module1 has the following translator:
@@ -202,7 +201,7 @@ and module2 has the following similar translator:
202201
203202
then which translator handles the invalid_argument will be determined by the
204203
order that module1 and module2 are imported. Since exception translators are
205-
applied in the reverse order of registration, which ever module was imported
204+
applied in the reverse order of registration, whichever module was imported
206205
last will "win" and that translator will be applied.
207206

208207
If there are multiple pybind11 modules that share exception types (either

0 commit comments

Comments
 (0)