@@ -314,16 +314,16 @@ inline internals **&get_internals_pp() {
314
314
return internals_pp;
315
315
}
316
316
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 ();
319
319
320
320
// Apply all the extensions translators from a list
321
321
// Return true if one of the translators completed without raising an exception
322
322
// itself. Return of false indicates that if there are other translators
323
323
// 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,
325
325
std::exception_ptr last_exception) {
326
- for (auto &translator : translators) {
326
+ for (const auto &translator : translators) {
327
327
try {
328
328
translator (last_exception);
329
329
return true ;
@@ -334,7 +334,7 @@ inline bool apply_exception_translators(std::forward_list<ExceptionTranslator> &
334
334
return false ;
335
335
}
336
336
337
- inline bool apply_exception_translators (std::forward_list<ExceptionTranslator> &translators) {
337
+ inline bool apply_exception_translators (const std::forward_list<ExceptionTranslator> &translators) {
338
338
return apply_exception_translators (translators, std::current_exception ());
339
339
}
340
340
@@ -343,12 +343,12 @@ template <class T,
343
343
bool handle_nested_exception (const T &exc, const std::exception_ptr &p) {
344
344
std::exception_ptr nested = exc.nested_ptr ();
345
345
if (nested != nullptr && nested != p) {
346
- auto &local_translators = get_local_exception_translators ();
346
+ const auto &local_translators = get_local_exception_translators ();
347
347
if (apply_exception_translators (local_translators, nested)) {
348
348
return true ;
349
349
}
350
350
351
- auto &translators = get_exception_translators ();
351
+ const auto &translators = get_exception_translators ();
352
352
if (apply_exception_translators (translators, nested)) {
353
353
return true ;
354
354
}
@@ -521,7 +521,7 @@ PYBIND11_NOINLINE internals &get_internals() {
521
521
return **internals_pp;
522
522
}
523
523
524
- inline std::forward_list<ExceptionTranslator> & get_exception_translators () {
524
+ inline const std::forward_list<ExceptionTranslator>& get_exception_translators () {
525
525
return get_internals ().registered_exception_translators ;
526
526
}
527
527
@@ -581,7 +581,7 @@ inline local_internals &get_local_internals() {
581
581
return *locals;
582
582
}
583
583
584
- inline std::forward_list<ExceptionTranslator> & get_local_exception_translators () {
584
+ inline const std::forward_list<ExceptionTranslator>& get_local_exception_translators () {
585
585
return get_local_internals ().registered_exception_translators ;
586
586
}
587
587
0 commit comments