René's URL Explorer Experiment


Title: line number for a return in a with block after 3.10 is that of the with, not the return statement · Issue #93975 · python/cpython · GitHub

Open Graph Title: line number for a return in a with block after 3.10 is that of the with, not the return statement · Issue #93975 · python/cpython

X Title: line number for a return in a with block after 3.10 is that of the with, not the return statement · Issue #93975 · python/cpython

Description: def foo() -> int: with open('/dev/null') as devnull: return 'a' In Python 3.10 onwards, the reported line number for the return statement is incorrect. Python main 3.12-main-ish not far from 3.11: >>> def foo() -> int: ... with open('a')...

Open Graph Description: def foo() -> int: with open('/dev/null') as devnull: return 'a' In Python 3.10 onwards, the reported line number for the return statement is incorrect. Python main 3.12-main-ish not far from 3.11: ...

X Description: def foo() -> int: with open('/dev/null') as devnull: return 'a' In Python 3.10 onwards, the reported line number for the return statement is incorrect. Python main 3.12-main-ish ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"line number for a return in a with block after 3.10 is that of the with, not the return statement","articleBody":"```python\r\ndef foo() -\u003e int:\r\n    with open('/dev/null') as devnull:\r\n        return 'a'\r\n```\r\n\r\nIn Python 3.10 onwards, the reported line number for the `return` statement is incorrect.\r\n\r\nPython main 3.12-main-ish not far from 3.11:\r\n\r\n```\r\n\u003e\u003e\u003e def foo() -\u003e int:\r\n...   with open('a') as f:\r\n...     return 'b'\r\n... \r\n\u003e\u003e\u003e dis.dis(foo)\r\n  1           0 RESUME                   0\r\n\r\n  2           2 LOAD_GLOBAL              1 (NULL + open)\r\n             14 LOAD_CONST               1 ('a')\r\n             16 CALL                     1\r\n             26 BEFORE_WITH\r\n             28 STORE_FAST               0 (f)\r\n\r\n  3          30 NOP\r\n\r\n  2          32 LOAD_CONST               0 (None)\r\n             34 LOAD_CONST               0 (None)\r\n             36 LOAD_CONST               0 (None)\r\n             38 CALL                     2\r\n             48 POP_TOP\r\n             50 LOAD_CONST               2 ('b')\r\n             52 RETURN_VALUE\r\n        \u003e\u003e   54 PUSH_EXC_INFO\r\n             56 WITH_EXCEPT_START\r\n             58 POP_JUMP_FORWARD_IF_TRUE     4 (to 68)\r\n             60 RERAISE                  2\r\n        \u003e\u003e   62 COPY                     3\r\n             64 POP_EXCEPT\r\n             66 RERAISE                  1\r\n        \u003e\u003e   68 POP_TOP\r\n             70 POP_EXCEPT\r\n             72 POP_TOP\r\n             74 POP_TOP\r\n             76 LOAD_CONST               0 (None)\r\n             78 RETURN_VALUE\r\nExceptionTable:\r\n  28 to 30 -\u003e 54 [1] lasti\r\n  54 to 60 -\u003e 62 [3] lasti\r\n  68 to 68 -\u003e 62 [3] lasti\r\n\u003e\u003e\u003e sys.version_info\r\nsys.version_info(major=3, minor=12, micro=0, releaselevel='alpha', serial=0)\r\n```\r\n\r\nThe only thing attributed to line 3 is a NOP.  The RETURN_VALUE of 'b' is listed as line 2. That is wrong.\r\n\r\nPython 3.9:\r\n\r\n```\r\n\u003e\u003e\u003e def foo() -\u003e int:\r\n...   with open('a') as f:\r\n...     return 'b'\r\n... \r\n\u003e\u003e\u003e dis.dis(foo)\r\n  2           0 LOAD_GLOBAL              0 (open)\r\n              2 LOAD_CONST               1 ('a')\r\n              4 CALL_FUNCTION            1\r\n              6 SETUP_WITH              18 (to 26)\r\n              8 STORE_FAST               0 (f)\r\n\r\n  3          10 POP_BLOCK\r\n             12 LOAD_CONST               0 (None)\r\n             14 DUP_TOP\r\n             16 DUP_TOP\r\n             18 CALL_FUNCTION            3\r\n             20 POP_TOP\r\n             22 LOAD_CONST               2 ('b')\r\n             24 RETURN_VALUE\r\n        \u003e\u003e   26 WITH_EXCEPT_START\r\n             28 POP_JUMP_IF_TRUE        32\r\n             30 RERAISE\r\n        \u003e\u003e   32 POP_TOP\r\n             34 POP_TOP\r\n             36 POP_TOP\r\n             38 POP_EXCEPT\r\n             40 POP_TOP\r\n             42 LOAD_CONST               0 (None)\r\n             44 RETURN_VALUE\r\n\u003e\u003e\u003e sys.version_info\r\nsys.version_info(major=3, minor=9, micro=12, releaselevel='final', serial=0)\r\n```\r\n\r\nNoticed by @martindemello working on a 3.10 error attribution bug in pytype.","author":{"url":"https://github.com/gpshead","@type":"Person","name":"gpshead"},"datePublished":"2022-06-18T00:05:07.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/93975/cpython/issues/93975"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4c9911b1-ddd6-e078-1ef5-bace564335b3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD534:169ED8:135D210:19F8A8A:6969AD59
html-safe-nonce01a7f8b9e2f943df1c6f19f79bb56d3c2db209078006411efbff0d207563a938
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTM0OjE2OUVEODoxMzVEMjEwOjE5RjhBOEE6Njk2OUFENTkiLCJ2aXNpdG9yX2lkIjoiMzgwNzg2MTg4ODM1OTQ0MzgwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacec4ed2c6bbb341b224745f622d2939c6b51abeace93c867b19d0829ed4f0f82d
hovercard-subject-tagissue:1275601441
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/93975/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9f3d147eeafecde60bfb8a5d9c0e98f74435547f332d076e3ae98d89e910248f/python/cpython/issues/93975
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9f3d147eeafecde60bfb8a5d9c0e98f74435547f332d076e3ae98d89e910248f/python/cpython/issues/93975
og:image:altdef foo() -> int: with open('/dev/null') as devnull: return 'a' In Python 3.10 onwards, the reported line number for the return statement is incorrect. Python main 3.12-main-ish not far from 3.11: ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamegpshead
hostnamegithub.com
expected-hostnamegithub.com
None24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7
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
release124667f43168afb6c9c03b7c02eb5b1d2e1be3d9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/93975#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F93975
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F93975
Sign up https://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/93975
Reloadhttps://github.com/python/cpython/issues/93975
Reloadhttps://github.com/python/cpython/issues/93975
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/93975
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/93975
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/93975
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/93975
line number for a return in a with block after 3.10 is that of the with, not the return statementhttps://github.com/python/cpython/issues/93975#top
https://github.com/markshannon
3.10only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.10%22
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/gpshead
https://github.com/gpshead
gpsheadhttps://github.com/gpshead
on Jun 18, 2022https://github.com/python/cpython/issues/93975#issue-1275601441
@martindemellohttps://github.com/martindemello
markshannonhttps://github.com/markshannon
3.10only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.10%22
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
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.