René's URL Explorer Experiment


Title: 3.13 Regression: `inspect.getsource()` returns incorrect source code · Issue #122981 · python/cpython · GitHub

Open Graph Title: 3.13 Regression: `inspect.getsource()` returns incorrect source code · Issue #122981 · python/cpython

X Title: 3.13 Regression: `inspect.getsource()` returns incorrect source code · Issue #122981 · python/cpython

Description: Bug report Bug description: In Python 3.13rc1, inspect.getsource() sometimes returns a "random" line for some objects. For example, here's ssl.AlertDescription: $ docker run --rm python:3.13-rc python -c "import inspect, ssl; print(inspe...

Open Graph Description: Bug report Bug description: In Python 3.13rc1, inspect.getsource() sometimes returns a "random" line for some objects. For example, here's ssl.AlertDescription: $ docker run --rm python:3.13-rc pyt...

X Description: Bug report Bug description: In Python 3.13rc1, inspect.getsource() sometimes returns a "random" line for some objects. For example, here's ssl.AlertDescription: $ docker run --rm pyth...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"3.13 Regression: `inspect.getsource()` returns incorrect source code","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nIn Python 3.13rc1, `inspect.getsource()` sometimes returns a \"random\" line for some objects. \r\nFor example, here's [`ssl.AlertDescription`](https://github.com/python/cpython/blob/v3.13.0rc1/Lib/ssl.py#L133-L136):\r\n\r\n```shell\r\n$ docker run --rm python:3.13-rc python -c \"import inspect, ssl; print(inspect.getsource(ssl.AlertDescription))\"\r\n        super().shutdown(how)\r\n```\r\nThis line is likely https://github.com/python/cpython/blob/v3.13.0rc1/Lib/ssl.py#L1334.\r\n\r\nIn contrast, on 3.12 and below, this raises an OSError (not ideal but also not wrong):\r\n\r\n```shell\r\n$ docker run --rm python:3.12-rc python -c \"import inspect, ssl; print(inspect.getsource(ssl.AlertDescription))\"\r\nTraceback (most recent call last):\r\n  File \"\u003cstring>\", line 1, in \u003cmodule>\r\n  File \"/usr/local/lib/python3.12/inspect.py\", line 1285, in getsource\r\n    lines, lnum = getsourcelines(object)\r\n                  ^^^^^^^^^^^^^^^^^^^^^^\r\n  File \"/usr/local/lib/python3.12/inspect.py\", line 1267, in getsourcelines\r\n    lines, lnum = findsource(object)\r\n                  ^^^^^^^^^^^^^^^^^^\r\n  File \"/usr/local/lib/python3.12/inspect.py\", line 1112, in findsource\r\n    raise OSError('could not find class definition')\r\nOSError: could not find class definition\r\n```\r\n\r\nI'm not sure why this is happening, but it also affects [pytest.PytestAssertRewriteWarning](https://github.com/pytest-dev/pytest/blob/38ad84bafd18d15ceff1960d636c693560337844/src/_pytest/warning_types.py#L20) and [pluggy.PluggyTeardownRaisedWarning](https://github.com/pytest-dev/pluggy/blob/5c16e15a963d5e66f37d05b1ccfb90adf71e8e0f/src/pluggy/_warnings.py#L11), which both extend custom classes that override `__module__`.\r\n\r\n### CPython versions tested on:\r\n\r\n3.8, 3.9, 3.10, 3.11, 3.12, 3.13\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-123001\n* gh-123182\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/mhils","@type":"Person","name":"mhils"},"datePublished":"2024-08-13T18:25:37Z","url":"https://github.com/python/cpython/issues/122981"}

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:2889ac06-a894-10e7-7b6a-3b5968b287e5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCD44:1188C0:13A7BD9:1A01488:6B065F5E
html-safe-nonce5878a6e4fcbb48911c50f5622f72118311d2ee25f95fe6d381b3e1eed6e31bfe
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDQ0OjExODhDMDoxM0E3QkQ5OjFBMDE0ODg6NkIwNjVGNUUiLCJ2aXNpdG9yX2lkIjoiMjQxMzk1ODM4MzQ4NTgyNzUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacd600f6545c4c042a29016e72b269e476565269e56f279949530a78b53bae6831
hovercard-subject-tagissue:2463957418
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/122981/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3a1c5561fa6b7c628a5ec4e772f5754b70f50c0cfa2f9560500ad6da01f2c783/python/cpython/issues/122981
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3a1c5561fa6b7c628a5ec4e772f5754b70f50c0cfa2f9560500ad6da01f2c783/python/cpython/issues/122981
og:image:altBug report Bug description: In Python 3.13rc1, inspect.getsource() sometimes returns a "random" line for some objects. For example, here's ssl.AlertDescription: $ docker run --rm python:3.13-rc pyt...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemhils
hostnamegithub.com
expected-hostnamegithub.com
None6324e6ac990fb6befbec840cc0e102a1071c339bfe8f9826bb12de2e3ba1d297
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
release7f0aa75f4141d440c6110dc31af7ea7797abb6c4
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/122981#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F122981
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%2F122981
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/122981
Reloadhttps://github.com/python/cpython/issues/122981
Reloadhttps://github.com/python/cpython/issues/122981
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/122981
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/122981
3.13 Regression: inspect.getsource() returns incorrect source codehttps://github.com/python/cpython/issues/122981#top
3.13https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
stdlibhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-bughttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/mhils
mhilshttps://github.com/mhils
on Aug 13, 2024https://github.com/python/cpython/issues/122981#issue-2463957418
ssl.AlertDescriptionhttps://github.com/python/cpython/blob/v3.13.0rc1/Lib/ssl.py#L133-L136
https://github.com/python/cpython/blob/v3.13.0rc1/Lib/ssl.py#L1334https://github.com/python/cpython/blob/v3.13.0rc1/Lib/ssl.py#L1334
pytest.PytestAssertRewriteWarninghttps://github.com/pytest-dev/pytest/blob/38ad84bafd18d15ceff1960d636c693560337844/src/_pytest/warning_types.py#L20
pluggy.PluggyTeardownRaisedWarninghttps://github.com/pytest-dev/pluggy/blob/5c16e15a963d5e66f37d05b1ccfb90adf71e8e0f/src/pluggy/_warnings.py#L11
gh-122981: Fix inspect.getsource() for generated classes with Python base classes #123001https://github.com/python/cpython/pull/123001
[3.13] gh-122981: Fix inspect.getsource() for generated classes with Python base classes (GH-123001) #123182https://github.com/python/cpython/pull/123182
mhilshttps://github.com/mhils
type-bughttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Aug 13, 2024https://github.com/python/cpython/issues/122981#event-13867502314
https://github.com/devdanzin
devdanzinhttps://github.com/devdanzin
on Aug 14, 2024https://github.com/python/cpython/issues/122981#issuecomment-2287718406
153b3f7https://github.com/python/cpython/commit/153b3f75306b5d26e29ea157105d0fdc247ef853
#118475https://github.com/python/cpython/pull/118475
@serhiy-storchakahttps://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Aug 14, 2024https://github.com/python/cpython/issues/122981#event-13875730030
pythongh-122981: Fix inspect.getsource() for generated classes with P…https://github.com/serhiy-storchaka/cpython/commit/6ee8a73bac305c3a8fb84939cf93d5b081116ea5
pythongh-122981https://github.com/python/cpython/issues/122981
6ee8a73https://github.com/serhiy-storchaka/cpython/commit/6ee8a73bac305c3a8fb84939cf93d5b081116ea5
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Aug 14, 2024https://github.com/python/cpython/issues/122981#issuecomment-2288078790
@mhilshttps://github.com/mhils
@devdanzinhttps://github.com/devdanzin
#123001https://github.com/python/cpython/pull/123001
serhiy-storchakahttps://github.com/serhiy-storchaka
3.13https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
stdlibhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
on Aug 14, 2024https://github.com/python/cpython/issues/122981#event-13875796640
serhiy-storchakahttps://github.com/serhiy-storchaka
Inspect issues 🔍https://github.com/orgs/python/projects/45
on Aug 14, 2024https://github.com/python/cpython/issues/122981#event-14790423202
serhiy-storchakahttps://github.com/serhiy-storchaka
Inspect issues 🔍https://github.com/orgs/python/projects/45
on Aug 14, 2024https://github.com/python/cpython/issues/122981
serhiy-storchakahttps://github.com/serhiy-storchaka
on Aug 14, 2024https://github.com/python/cpython/issues/122981#event-13876076606
pythongh-122981: Fix inspect.getsource() for generated classes with P…https://github.com/serhiy-storchaka/cpython/commit/36e96ba317498accfd66c2bd872c81496b2d620f
pythongh-122981https://github.com/python/cpython/issues/122981
36e96bahttps://github.com/serhiy-storchaka/cpython/commit/36e96ba317498accfd66c2bd872c81496b2d620f
https://github.com/mhils
mhilshttps://github.com/mhils
on Aug 14, 2024https://github.com/python/cpython/issues/122981#issuecomment-2288807756
serhiy-storchakahttps://github.com/serhiy-storchaka
on Aug 20, 2024https://github.com/python/cpython/issues/122981#event-13948358509
gh-122981: Fix inspect.getsource() for generated classes with Python …https://github.com/python/cpython/commit/f88c14d412522587085ae039ebe70b91d5b4e226
gh-122981https://github.com/python/cpython/issues/122981
f88c14dhttps://github.com/python/cpython/commit/f88c14d412522587085ae039ebe70b91d5b4e226
miss-islingtonhttps://github.com/miss-islington
on Aug 20, 2024https://github.com/python/cpython/issues/122981#event-13948359908
pythongh-122981: Fix inspect.getsource() for generated classes with P…https://github.com/miss-islington/cpython/commit/f19222e86e099c3140262c12ca081d23fa3a1f07
pythongh-122981https://github.com/python/cpython/issues/122981
f19222ehttps://github.com/miss-islington/cpython/commit/f19222e86e099c3140262c12ca081d23fa3a1f07
blhsinghttps://github.com/blhsing
on Aug 22, 2024https://github.com/python/cpython/issues/122981#event-13974057547
pythongh-122981: Fix inspect.getsource() for generated classes with P…https://github.com/blhsing/cpython/commit/7fb20410c41e38f08ddf99171cedea2533501fa0
pythongh-122981https://github.com/python/cpython/issues/122981
7fb2041https://github.com/blhsing/cpython/commit/7fb20410c41e38f08ddf99171cedea2533501fa0
Yhg1shttps://github.com/Yhg1s
on Sep 2, 2024https://github.com/python/cpython/issues/122981#event-14101751797
[3.13] gh-122981: Fix inspect.getsource() for generated classes with …https://github.com/python/cpython/commit/2b4c31d87d6fe9ec7cdc88eb6139ce9370666739
gh-122981https://github.com/python/cpython/issues/122981
2b4c31dhttps://github.com/python/cpython/commit/2b4c31d87d6fe9ec7cdc88eb6139ce9370666739
https://github.com/mhils
mhilshttps://github.com/mhils
on Sep 10, 2024https://github.com/python/cpython/issues/122981#issuecomment-2341388356
https://github.com/mitmproxy/pdoc/actions/runs/10772390037/job/29935976461?pr=730https://github.com/mitmproxy/pdoc/actions/runs/10772390037/job/29935976461?pr=730
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on Sep 11, 2024https://github.com/python/cpython/issues/122981#issuecomment-2342864475
#123339https://github.com/python/cpython/issues/123339
serhiy-storchakahttps://github.com/serhiy-storchaka
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Sep 11, 2024https://github.com/python/cpython/issues/122981#event-14210952155
github-project-automationhttps://github.com/apps/github-project-automation
Inspect issues 🔍https://github.com/orgs/python/projects/45
on Sep 11, 2024https://github.com/python/cpython/issues/122981
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/122981
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/122981
3.13https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
3.14https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.14%22
stdlibhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22stdlib%22
type-bughttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
Inspect issues 🔍https://github.com/orgs/python/projects/45
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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.