@@ -1610,7 +1610,10 @@ Casting
16101610 When the `convert ` argument is set to ``true `` (the default), the
16111611 implementation may also attempt *implicit conversions * to perform the cast.
16121612
1613- The function raises a :cpp:type: `cast_error ` when the conversion fails.
1613+ The function raises an exception when the conversion fails.
1614+ If the type caster uses the CPython error API (e.g., ``PyErr_SetString() ``
1615+ or ``PyErr_Format() ``) to report a failure, then :cpp:class: `python_error `
1616+ is raised. Otherwise, :cpp:type: `cast_error ` is raised.
16141617 See :cpp:func: `try_cast() ` for an alternative that never raises.
16151618
16161619.. cpp :function :: template <typename T, typename Derived> bool try_cast (const detail::api<Derived> &value, T &out, bool convert = true) noexcept
@@ -1632,7 +1635,10 @@ Casting
16321635 policy `policy ` is used to handle ownership-related questions when a new
16331636 Python object must be created.
16341637
1635- The function raises a :cpp:type: `cast_error ` when the conversion fails.
1638+ The function raises an exception when the conversion fails.
1639+ If the type caster uses the CPython error API (e.g., ``PyErr_SetString() ``
1640+ or ``PyErr_Format() ``) to report a failure, then :cpp:class: `python_error `
1641+ is raised. Otherwise, :cpp:type: `cast_error ` is raised.
16361642
16371643.. cpp :function :: template <typename T> object cast (T &&value, rv_policy policy, handle parent)
16381644
@@ -1641,7 +1647,10 @@ Casting
16411647 Python object must be created. A valid `parent ` object is required when
16421648 specifying a `reference_internal ` return value policy.
16431649
1644- The function raises a :cpp:type: `cast_error ` when the conversion fails.
1650+ The function raises an exception when the conversion fails.
1651+ If the type caster uses the CPython error API (e.g., ``PyErr_SetString() ``
1652+ or ``PyErr_Format() ``) to report a failure, then :cpp:class: `python_error `
1653+ is raised. Otherwise, :cpp:type: `cast_error ` is raised.
16451654
16461655.. cpp :function :: template <typename T> object find (const T &value) noexcept
16471656
@@ -1655,7 +1664,10 @@ Casting
16551664 value policy `policy ` is used to handle ownership-related questions when a
16561665 new Python objects must be created.
16571666
1658- The function raises a :cpp:type: `cast_error ` when the conversion fails.
1667+ The function raises an exception when the conversion fails.
1668+ If the type caster uses the CPython error API (e.g., ``PyErr_SetString() ``
1669+ or ``PyErr_Format() ``) to report a failure, then :cpp:class: `python_error `
1670+ is raised. Otherwise, :cpp:type: `cast_error ` is raised.
16591671
16601672Common binding annotations
16611673--------------------------
0 commit comments