René's URL Explorer Experiment


Title: wrong/ambiguous type descriptions for `LogRecord.exc_info` · Issue #161918 · python/cpython · GitHub

Open Graph Title: wrong/ambiguous type descriptions for `LogRecord.exc_info` · Issue #161918 · python/cpython

X Title: wrong/ambiguous type descriptions for `LogRecord.exc_info` · Issue #161918 · python/cpython

Description: Documentation Hey. The documentation of LogRecord describes the exc_info attribute as: exc_info (tuple[type[BaseException], BaseException, types.TracebackType] | None) – An exception tuple with the current exception information, as retur...

Open Graph Description: Documentation Hey. The documentation of LogRecord describes the exc_info attribute as: exc_info (tuple[type[BaseException], BaseException, types.TracebackType] | None) – An exception tuple with the...

X Description: Documentation Hey. The documentation of LogRecord describes the exc_info attribute as: exc_info (tuple[type[BaseException], BaseException, types.TracebackType] | None) – An exception tuple with the...

Opengraph URL: https://github.com/python/cpython/issues/161918

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"wrong/ambiguous type descriptions for `LogRecord.exc_info`","articleBody":"### Documentation\n\nHey.\n\nThe [documentation of `LogRecord`](https://docs.python.org/3/library/logging.html#logrecord-objects) describes the `exc_info` attribute as:\n\n> exc_info (tuple[type[BaseException], BaseException, types.TracebackType] | None) – An exception tuple with the current exception information, as returned by sys.exc_info(), or None if no exception information is available.\n\n\nHowever, records created through the normal logger methods can contain values that don’t match this type:\n```python\nimport logging\n\nclass H(logging.Handler):\n    def emit(self, record):\n        print(repr(record.exc_info))\n\nlogger = logging.getLogger()\nlogger.addHandler(H())\nlogger.propagate = False\n\nlogger.error(\"b\", exc_info=True)           # outside of an except-block\nlogger.error(\"c\", exc_info=ValueError())   # exception that was never raised\n```\nwhich gives as of CPython 3.14.10:\n```\n(None, None, None)\n(\u003cclass 'ValueError'>, ValueError(), None)\n```\nA very recent commit (938144efad4659f7aa66bf9ef362fd3c602c4bbc) already fixed the case of a false truth value, which as per [“If exc_info does not evaluate as false, …”](https://docs.python.org/3/library/logging.html#logging.Logger.debug) is IMO allowed.\n\nNow:\n1. [Outside an `except`-block it would be `(None, None, None)`.](https://docs.python.org/3/library/sys.html#sys.exc_info)\n2. If an exception instance is passed, the tuple is built from its [__traceback__](url), which is [None](url) for exceptions that were never raised, while the documented type requires [types.TracebackType](url).\n\nI think typeshed already documents it properly:\nhttps://github.com/python/typeshed/blob/80f7beabfbb71a634cc3dbca8e418a5da790142c/stdlib/logging/__init__.pyi#L63\n\nhttps://github.com/python/typeshed/blob/80f7beabfbb71a634cc3dbca8e418a5da790142c/stdlib/logging/__init__.pyi#L318\n\nSo far I'd say this is a documentation issue.\n\nNow I can create valid `LogRecord`-objects that don’t go through `_log()` and its normalisation:\n```\n>>> import logging\n>>> l = logging.getLogger()\n>>> r = logging.makeLogRecord({\"exc_info\": True})\n>>> r.exc_info\nTrue\n>>> r = l.makeRecord(\"z\", 40, \"f\", 1, \"m\", None, exc_info=False)\n>>> r.exc_info\nFalse\n>>>\n```\nFor `makeLogRecord` and `makeRecord`… it’s IMO not really clear what values these allow (de jure) for `exc_info`.\nIf they’d follow the spirit of “If exc_info does not evaluate as false, …” then the the above type description would be even more wrong, as then `exc_info` could be any object.\n\nThis would then IMO also make the types on typeshed wrong, cause while `logging.Formatter.format()` itself would call `formatException()` only if `exc_info` has a true truth value:\nhttps://github.com/python/cpython/blob/ecefd40671f340d543c214b80744d4301d249f37/Lib/logging/__init__.py#L716-L720\n\nthat may be still any object, there's nothing for the false case and both `format()` and `formatException()` are public, so any subclass may call `formatException()` without the `if record.exc_info:`.\n\nLast but not least:\n[`formatException()` is more or less documented](https://docs.python.org/3/library/logging.html#logging.Formatter.formatException) to an even more restrictive type:\n\n> Formats the specified exception information (a standard exception tuple as returned by sys.exc_info()) as a string.\n\nSo not sure,... at least some documentation seems to be not exact... but maybe there also needs to be code changes if the normalisation of `exc_info` should happen not only via `LogRecord` objects created through `_log()`... and if not, typeshed might need some updates to account for values that may be given.\n\nCheers,\nChris\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-162179\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/calestyo","@type":"Person","name":"calestyo"},"datePublished":"2026-11-13T00:08:42Z","url":"https://github.com/python/cpython/issues/161918"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:c5037f29-d95d-dca4-31ca-590028fe75b5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id86AA:3CBF1A:1A70C82:23F8F6D:6B0006D6
html-safe-nonce14f152c792fec9828b6911fc1945f2c74b3c9ee8998cd05d9063e91cd7383a5b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NkFBOjNDQkYxQToxQTcwQzgyOjIzRjhGNkQ6NkIwMDA2RDYiLCJ2aXNpdG9yX2lkIjoiODI1NDQ3MzU5MTg2NTczODk2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac2377b75c582829e5cf0dc8f1bf9f8cb1a912ca69edc41ad27bfedd2ee035a65c
hovercard-subject-tagissue:6361725786
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/161918/issue_layout
twitter:imagehttps://opengraph.githubassets.com/20bd8e7814969b61bce203c90fcdc2ad6b77543ccd5cbeb3e68300eb3e03a48c/python/cpython/issues/161918
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/20bd8e7814969b61bce203c90fcdc2ad6b77543ccd5cbeb3e68300eb3e03a48c/python/cpython/issues/161918
og:image:altDocumentation Hey. The documentation of LogRecord describes the exc_info attribute as: exc_info (tuple[type[BaseException], BaseException, types.TracebackType] | None) – An exception tuple with the...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecalestyo
hostnamegithub.com
expected-hostnamegithub.com
None0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release16a11879678aaf97e2a42c33ee70830aa084fa37
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/161918#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F161918
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F161918
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/161918
Reloadhttps://github.com/python/cpython/issues/161918
Reloadhttps://github.com/python/cpython/issues/161918
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/161918
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/161918
wrong/ambiguous type descriptions for LogRecord.exc_infohttps://github.com/python/cpython/issues/161918#top
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
https://github.com/calestyo
calestyohttps://github.com/calestyo
on Nov 13, 2026https://github.com/python/cpython/issues/161918#issue-6361725786
documentation of LogRecordhttps://docs.python.org/3/library/logging.html#logrecord-objects
938144ehttps://github.com/python/cpython/commit/938144efad4659f7aa66bf9ef362fd3c602c4bbc
“If exc_info does not evaluate as false, …”https://docs.python.org/3/library/logging.html#logging.Logger.debug
Outside an except-block it would be (None, None, None).https://docs.python.org/3/library/sys.html#sys.exc_info
tracebackhttps://github.com/python/cpython/issues/url
Nonehttps://github.com/python/cpython/issues/url
types.TracebackTypehttps://github.com/python/cpython/issues/url
https://github.com/python/typeshed/blob/80f7beabfbb71a634cc3dbca8e418a5da790142c/stdlib/logging/__init__.pyi#L63https://github.com/python/typeshed/blob/80f7beabfbb71a634cc3dbca8e418a5da790142c/stdlib/logging/__init__.pyi#L63
https://github.com/python/typeshed/blob/80f7beabfbb71a634cc3dbca8e418a5da790142c/stdlib/logging/__init__.pyi#L318https://github.com/python/typeshed/blob/80f7beabfbb71a634cc3dbca8e418a5da790142c/stdlib/logging/__init__.pyi#L318
cpython/Lib/logging/__init__.pyhttps://github.com/python/cpython/blob/ecefd40671f340d543c214b80744d4301d249f37/Lib/logging/__init__.py#L716-L720
ecefd40https://github.com/python/cpython/commit/ecefd40671f340d543c214b80744d4301d249f37
formatException() is more or less documentedhttps://docs.python.org/3/library/logging.html#logging.Formatter.formatException
gh-161918: Correct the documented type of LogRecord's exc_info parameter #162179https://github.com/python/cpython/pull/162179
calestyohttps://github.com/calestyo
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
on Nov 13, 2026https://github.com/python/cpython/issues/161918#event-35976713792
github-project-automationhttps://github.com/apps/github-project-automation
docs issueshttps://github.com/orgs/python/projects/52
on Nov 13, 2026https://github.com/python/cpython/issues/161918#event-35976715343
github-project-automationhttps://github.com/apps/github-project-automation
docs issueshttps://github.com/orgs/python/projects/52
on Nov 13, 2026https://github.com/python/cpython/issues/161918
https://github.com/calestyo
calestyohttps://github.com/calestyo
on Nov 13, 2026https://github.com/python/cpython/issues/161918#issuecomment-6839995023
aiskhttps://github.com/aisk
Logging issues 🪵https://github.com/orgs/python/projects/15
on Nov 13, 2026https://github.com/python/cpython/issues/161918#event-35983589501
https://github.com/calestyo
calestyohttps://github.com/calestyo
on Nov 13, 2026https://github.com/python/cpython/issues/161918#issuecomment-6846299140
cpython/Lib/logging/__init__.pyhttps://github.com/python/cpython/blob/ecefd40671f340d543c214b80744d4301d249f37/Lib/logging/__init__.py#L725-L728
ecefd40https://github.com/python/cpython/commit/ecefd40671f340d543c214b80744d4301d249f37
https://github.com/python/typeshed/blob/80f7beabfbb71a634cc3dbca8e418a5da790142c/stdlib/logging/__init__.pyi#L290https://github.com/python/typeshed/blob/80f7beabfbb71a634cc3dbca8e418a5da790142c/stdlib/logging/__init__.pyi#L290
https://github.com/calestyo
calestyohttps://github.com/calestyo
on Nov 15, 2026https://github.com/python/cpython/issues/161918#issuecomment-6902990950
@anbv29https://github.com/anbv29
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/161918
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/161918
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
Logging issues 🪵https://github.com/orgs/python/projects/15
docs issueshttps://github.com/orgs/python/projects/52
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.