Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fixes:
- |
Strip the ``str`` representation of the exception to avoid multiline
log output from ``before_sleep()`` when some exceptions include ``\n``
characters at the end of their string representation.
3 changes: 2 additions & 1 deletion tenacity/before_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def log_it(retry_state: "RetryCallState") -> None:

if retry_state.outcome.failed:
ex = retry_state.outcome.exception()
verb, value = "raised", f"{ex.__class__.__name__}: {ex}"
exception_str = str(ex).strip() # Ensure message isn't multiline.
verb, value = "raised", f"{ex.__class__.__name__}: {exception_str}"

if exc_info:
local_exc_info = retry_state.outcome.exception()
Expand Down