From c6cf0911fc30f78ebf7b515a9b16ca1db77e981b Mon Sep 17 00:00:00 2001 From: Tom Kuson Date: Sat, 3 Oct 2026 13:56:44 +0200 Subject: [PATCH] Allow LogRecord.exc_info to be False --- stdlib/logging/__init__.pyi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stdlib/logging/__init__.pyi b/stdlib/logging/__init__.pyi index 39bd64694a1e..a8d0fb78e3ce 100644 --- a/stdlib/logging/__init__.pyi +++ b/stdlib/logging/__init__.pyi @@ -225,7 +225,7 @@ class Logger(Filterer): lno: int, msg: object, args: _ArgsType, - exc_info: _SysExcInfoType | None, + exc_info: _SysExcInfoType | Literal[False] | None, func: str | None = None, extra: Mapping[str, object] | None = None, sinfo: str | None = None, @@ -312,7 +312,9 @@ class LogRecord: args: _ArgsType | None asctime: str created: float - exc_info: _SysExcInfoType | None + # Logger._log() only normalizes truthy exc_info values so + # exc_info=False ends up on the record unchanged. + exc_info: _SysExcInfoType | Literal[False] | None exc_text: str | None filename: str funcName: str @@ -343,7 +345,7 @@ class LogRecord: lineno: int, msg: object, args: _ArgsType | None, - exc_info: _SysExcInfoType | None, + exc_info: _SysExcInfoType | Literal[False] | None, func: str | None = None, sinfo: str | None = None, ) -> None: ...