Title: `inspect.getsourcelines()` mishandles multi-line generator expressions · Issue #137477 · python/cpython · GitHub
Open Graph Title: `inspect.getsourcelines()` mishandles multi-line generator expressions · Issue #137477 · python/cpython
X Title: `inspect.getsourcelines()` mishandles multi-line generator expressions · Issue #137477 · python/cpython
Description: Bug report Bug description: import inspect def source_error(*args): frame = inspect.currentframe() if frame is None: return frame = frame.f_back if frame is None: return print(inspect.getsource(frame)) def demo(): loops = ( None for _ in...
Open Graph Description: Bug report Bug description: import inspect def source_error(*args): frame = inspect.currentframe() if frame is None: return frame = frame.f_back if frame is None: return print(inspect.getsource(fra...
X Description: Bug report Bug description: import inspect def source_error(*args): frame = inspect.currentframe() if frame is None: return frame = frame.f_back if frame is None: return print(inspect.getsource(fra...
Opengraph URL: https://github.com/python/cpython/issues/137477
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`inspect.getsourcelines()` mishandles multi-line generator expressions","articleBody":"# Bug report\n\n### Bug description:\n\n```python\nimport inspect\n\ndef source_error(*args):\n frame = inspect.currentframe()\n if frame is None:\n return\n frame = frame.f_back\n if frame is None:\n return\n print(inspect.getsource(frame))\n\ndef demo():\n loops = (\n None for _ in [0] if source_error(True)\n )\n list(loops)\n\ndemo()\n```\nExpected output:\n```\ndef demo():\n loops = (\n None for _ in [0] if source_error(True)\n )\n list(loops)\n```\nActual output:\n```\n loops = (\n```\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-137479\n* gh-137488\n* gh-137993\n* gh-137995\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/George-Ogden","@type":"Person","name":"George-Ogden"},"datePublished":"2025-08-06T16:53:14Z","url":"https://github.com/python/cpython/issues/137477"}
| 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:5548380a-56af-edc3-7d72-904a484c0458 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C39C:3B6B85:12A8874:18AD2E9:6B065A8F |
| html-safe-nonce | 1894dfdcdb422441c999641da192eeaa6edee9ca7791fc0877401978729af004 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzlDOjNCNkI4NToxMkE4ODc0OjE4QUQyRTk6NkIwNjVBOEYiLCJ2aXNpdG9yX2lkIjoiNzU0OTQxNDAxOTcwNzU5MTMxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 22cdfa527822ad24022eeba5268a24734a63846a082e7c62f6edec09d5a14d62 |
| hovercard-subject-tag | issue:3297391823 |
| 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/137477/issue_layout |
| twitter:image | https://opengraph.githubassets.com/65224cb66b6e24aac057e6ced0577dadde7ae247846fdff34a97a962002d23cc/python/cpython/issues/137477 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/65224cb66b6e24aac057e6ced0577dadde7ae247846fdff34a97a962002d23cc/python/cpython/issues/137477 |
| og:image:alt | Bug report Bug description: import inspect def source_error(*args): frame = inspect.currentframe() if frame is None: return frame = frame.f_back if frame is None: return print(inspect.getsource(fra... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | George-Ogden |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6324e6ac990fb6befbec840cc0e102a1071c339bfe8f9826bb12de2e3ba1d297 |
| 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 | 7f0aa75f4141d440c6110dc31af7ea7797abb6c4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width