@@ -314,16 +314,16 @@ inline internals **&get_internals_pp() {
314314 return internals_pp;
315315}
316316
317- std::forward_list<ExceptionTranslator> & get_exception_translators ();
318- std::forward_list<ExceptionTranslator> & get_local_exception_translators ();
317+ const std::forward_list<ExceptionTranslator>& get_exception_translators ();
318+ const std::forward_list<ExceptionTranslator>& get_local_exception_translators ();
319319
320320// Apply all the extensions translators from a list
321321// Return true if one of the translators completed without raising an exception
322322// itself. Return of false indicates that if there are other translators
323323// available, they should be tried.
324- inline bool apply_exception_translators (std::forward_list<ExceptionTranslator> &translators,
324+ inline bool apply_exception_translators (const std::forward_list<ExceptionTranslator> &translators,
325325 std::exception_ptr last_exception) {
326- for (auto &translator : translators) {
326+ for (const auto &translator : translators) {
327327 try {
328328 translator (last_exception);
329329 return true ;
@@ -334,7 +334,7 @@ inline bool apply_exception_translators(std::forward_list<ExceptionTranslator> &
334334 return false ;
335335}
336336
337- inline bool apply_exception_translators (std::forward_list<ExceptionTranslator> &translators) {
337+ inline bool apply_exception_translators (const std::forward_list<ExceptionTranslator> &translators) {
338338 return apply_exception_translators (translators, std::current_exception ());
339339}
340340
@@ -343,12 +343,12 @@ template <class T,
343343bool handle_nested_exception (const T &exc, const std::exception_ptr &p) {
344344 std::exception_ptr nested = exc.nested_ptr ();
345345 if (nested != nullptr && nested != p) {
346- auto &local_translators = get_local_exception_translators ();
346+ const auto &local_translators = get_local_exception_translators ();
347347 if (apply_exception_translators (local_translators, nested)) {
348348 return true ;
349349 }
350350
351- auto &translators = get_exception_translators ();
351+ const auto &translators = get_exception_translators ();
352352 if (apply_exception_translators (translators, nested)) {
353353 return true ;
354354 }
@@ -521,7 +521,7 @@ PYBIND11_NOINLINE internals &get_internals() {
521521 return **internals_pp;
522522}
523523
524- inline std::forward_list<ExceptionTranslator> & get_exception_translators () {
524+ inline const std::forward_list<ExceptionTranslator>& get_exception_translators () {
525525 return get_internals ().registered_exception_translators ;
526526}
527527
@@ -581,7 +581,7 @@ inline local_internals &get_local_internals() {
581581 return *locals;
582582}
583583
584- inline std::forward_list<ExceptionTranslator> & get_local_exception_translators () {
584+ inline const std::forward_list<ExceptionTranslator>& get_local_exception_translators () {
585585 return get_local_internals ().registered_exception_translators ;
586586}
587587
0 commit comments