Title: PEP 669: for loop fires LINE multiple times for body, but only one for `for` · Issue #104239 · python/cpython · GitHub
Open Graph Title: PEP 669: for loop fires LINE multiple times for body, but only one for `for` · Issue #104239 · python/cpython
X Title: PEP 669: for loop fires LINE multiple times for body, but only one for `for` · Issue #104239 · python/cpython
Description: I'm experimenting with the new monitoring interface in PEP 669. The LINE event happens multiple times for the line in the body of a for loop (as I expect), but the for statement itself only gets an event on entering, not each time around...
Open Graph Description: I'm experimenting with the new monitoring interface in PEP 669. The LINE event happens multiple times for the line in the body of a for loop (as I expect), but the for statement itself only gets an...
X Description: I'm experimenting with the new monitoring interface in PEP 669. The LINE event happens multiple times for the line in the body of a for loop (as I expect), but the for statement itself only get...
Opengraph URL: https://github.com/python/cpython/issues/104239
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PEP 669: for loop fires LINE multiple times for body, but only one for `for`","articleBody":"I'm experimenting with the new monitoring interface in PEP 669. The LINE event happens multiple times for the line in the body of a for loop (as I expect), but the for statement itself only gets an event on entering, not each time around the loop.\r\n\r\nThis code:\r\n```python\r\nimport sys\r\n\r\ndef loop3():\r\n for i in range(3):\r\n print(i)\r\n print(\"done\")\r\n\r\nthe_code = loop3.__code__\r\n\r\ndef line_callback(code, line_number):\r\n assert code == the_code\r\n print(f\"LINE: {line_number}\")\r\n\r\nmy_id = sys.monitoring.COVERAGE_ID\r\nsys.monitoring.use_tool_id(my_id, \"repro\")\r\nsys.monitoring.register_callback(my_id, sys.monitoring.events.LINE, line_callback)\r\nsys.monitoring.set_local_events(my_id, the_code, sys.monitoring.events.LINE)\r\n\r\nloop3()\r\n```\r\nproduces:\r\n```\r\nLINE: 4\r\nLINE: 5\r\n0\r\nLINE: 5\r\n1\r\nLINE: 5\r\n2\r\nLINE: 6\r\ndone\r\n```\r\nI would expect Line 4 to be monitored after each \"LINE: 5\", including after the last one.\r\n\r\nThis is with commit 263abd333d of CPython.","author":{"url":"https://github.com/nedbat","@type":"Person","name":"nedbat"},"datePublished":"2023-05-06T16:34:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/104239/cpython/issues/104239"}
| 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:6c1b61b0-ae42-39be-6d6b-7c4f43cb2aba |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E79C:2B0240:653E38:8AA739:6969DBB8 |
| html-safe-nonce | 9b9fbf964733fccbc55b4cd28b2ca249ef35debc5ceeb45dde38e12a5ca8c5df |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzlDOjJCMDI0MDo2NTNFMzg6OEFBNzM5OjY5NjlEQkI4IiwidmlzaXRvcl9pZCI6IjgwNzUyMTA5ODk4NjgwMTQ1MjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0d74bbaa4a4dba26d83c83a8488fdb4586a79f705995f0d9798a06d2184ef81d |
| hovercard-subject-tag | issue:1698695490 |
| 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/104239/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3543943426a43f072c2cca73e969d7dd1fc8525d338cb6c88f68920d5407da1f/python/cpython/issues/104239 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3543943426a43f072c2cca73e969d7dd1fc8525d338cb6c88f68920d5407da1f/python/cpython/issues/104239 |
| og:image:alt | I'm experimenting with the new monitoring interface in PEP 669. The LINE event happens multiple times for the line in the body of a for loop (as I expect), but the for statement itself only gets an... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nedbat |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| 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 | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width