fix: don't break on IndexError in logging (#9068)

* fix: don't break on IndexError in logging

* add reno

* Update releasenotes/notes/fix-logging-index-error-c58691db633542c5.yaml

---------

Co-authored-by: David S. Batista <dsbatista@gmail.com>
This commit is contained in:
tstadel 2025-03-19 17:46:35 +01:00 committed by GitHub
parent 9fbfa9676f
commit 9a046ed431
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -192,7 +192,7 @@ def patch_make_records_to_use_kwarg_string_interpolation(original_make_records:
safe_extra = extra or {}
try:
interpolated_msg = msg.format(**safe_extra)
except (KeyError, ValueError):
except (KeyError, ValueError, IndexError):
interpolated_msg = msg
return original_make_records(name, level, fn, lno, interpolated_msg, (), exc_info, func, extra, sinfo)

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Fixed an index error in the logging module when arbitrary strings are logged.