Skip to content

Commit 07fe63e

Browse files
Ensure before_sleep_log message isn't multiline
Some exceptions add extra `\n` characters to their message, causing the last . in the log to be a new line.
1 parent 0d40e76 commit 07fe63e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tenacity/before_sleep.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def log_it(retry_state: "RetryCallState") -> None:
4646

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

5152
if exc_info:
5253
local_exc_info = retry_state.outcome.exception()

0 commit comments

Comments
 (0)