Title: `LogRecord` should normalize falsy `exc_info` values · Issue #158839 · python/cpython · GitHub
Open Graph Title: `LogRecord` should normalize falsy `exc_info` values · Issue #158839 · python/cpython
X Title: `LogRecord` should normalize falsy `exc_info` values · Issue #158839 · python/cpython
Description: Bug report Pointed out by @tjkuson in python/typeshed#16466 According to the documentation, the exc_info argument to the log() group of function can be any falsy value to indicate that no exception information is provided. It's common to...
Open Graph Description: Bug report Pointed out by @tjkuson in python/typeshed#16466 According to the documentation, the exc_info argument to the log() group of function can be any falsy value to indicate that no exception...
X Description: Bug report Pointed out by @tjkuson in python/typeshed#16466 According to the documentation, the exc_info argument to the log() group of function can be any falsy value to indicate that no exception...
Opengraph URL: https://github.com/python/cpython/issues/158839
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`LogRecord` should normalize falsy `exc_info` values","articleBody":"### Bug report\n\nPointed out by @tjkuson in python/typeshed#16466\n\n[According to the documentation](https://docs.python.org/3/library/logging.html#logging.Logger.debug), the `exc_info` argument to the `log()` group of function can be any falsy value to indicate that no exception information is provided. It's common to use either `None` or `False` here.\n\nWhen a truthy value is provided, it is normalized to an exception info tuple before passing it to `LogRecord`. A falsy value is passed on unchanged:\n\nhttps://github.com/python/cpython/blob/9112daed900c3314fa522043fc64ddbb2ecd4ca5/Lib/logging/__init__.py#L1678-L1682\n\nThis contradicts [LogRecords documentation](https://docs.python.org/3/library/logging.html#logging.LogRecord), which says that only `None` is accepted and that the `exc_info` field can be a tuple or `None`. The mypy primer run in python/typeshed#16466 shows that a few projects make this assumption. For example, [sphinx](https://github.com/sphinx-doc/sphinx/blob/b04a2101295ac3fb725b16111eda0284b6da4cca/sphinx/util/logging.py#L410-L411):\n\n```python\n if record.exc_info is not None:\n raise SphinxWarning(message) from record.exc_info[1]\n```\n\nSolution: Normalize falsy values to `None` before passing them to `makeRecord`.\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-158840\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/srittau","@type":"Person","name":"srittau"},"datePublished":"2026-10-05T12:51:13Z","url":"https://github.com/python/cpython/issues/158839"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2cd3bbd2-e9ea-0c4f-3f19-f8420b6d96e9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA22:27E6DD:13386D3:19378C0:6B0006DE |
| html-safe-nonce | d0b7be24648d01ec8e3b801dbdbcc24afadc2d234e964bdb8a0f88f8a9f0513f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTIyOjI3RTZERDoxMzM4NkQzOjE5Mzc4QzA6NkIwMDA2REUiLCJ2aXNpdG9yX2lkIjoiNTgzMzEzOTk5MDA5OTM5NjMxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 936ac61bbfdcc48994e170ba1c5e7a06c5071267133a546e8b4047306ea64f51 |
| hovercard-subject-tag | issue:5712304519 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/158839/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2f56a67d05cb59adf272c889a7af68992a6c309471b57cefacd33eaa10c171c3/python/cpython/issues/158839 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2f56a67d05cb59adf272c889a7af68992a6c309471b57cefacd33eaa10c171c3/python/cpython/issues/158839 |
| og:image:alt | Bug report Pointed out by @tjkuson in python/typeshed#16466 According to the documentation, the exc_info argument to the log() group of function can be any falsy value to indicate that no exception... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | srittau |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width