Title: `inspect.getargvalues` does not work correctly for pos-only and kw-only arguments · Issue #107833 · python/cpython · GitHub
Open Graph Title: `inspect.getargvalues` does not work correctly for pos-only and kw-only arguments · Issue #107833 · python/cpython
X Title: `inspect.getargvalues` does not work correctly for pos-only and kw-only arguments · Issue #107833 · python/cpython
Description: Here's an example: >>> fr = None >>> def a(p, /, a, *, b): ... global fr ... fr = inspect.currentframe() ... >>> a(1, 2, b=3) >>> fr ', line 3, code a> >>> inspect.getargvalues(fr) ArgInfo(args=['p', '...
Open Graph Description: Here's an example: >>> fr = None >>> def a(p, /, a, *, b): ... global fr ... fr = inspect.currentframe() ... >>> a(1, 2, b=3) >>> fr ', line 3, code a> >>> inspe...
X Description: Here's an example: >>> fr = None >>> def a(p, /, a, *, b): ... global fr ... fr = inspect.currentframe() ... >>> a(1, 2, b=3) >>> fr <frame at 0x101275570...
Opengraph URL: https://github.com/python/cpython/issues/107833
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`inspect.getargvalues` does not work correctly for pos-only and kw-only arguments","articleBody":"Here's an example:\r\n\r\n```python\r\n>>> fr = None\r\n>>> def a(p, /, a, *, b): \r\n... global fr\r\n... fr = inspect.currentframe()\r\n... \r\n>>> a(1, 2, b=3)\r\n>>> fr\r\n\u003cframe at 0x101275570, file '\u003cstdin>', line 3, code a>\r\n>>> inspect.getargvalues(fr)\r\nArgInfo(args=['p', 'a', 'b'], varargs=None, keywords=None, locals={'p': 1, 'a': 2, 'b': 3})\r\n```\r\n\r\nRight now `inspect.getargvalues` treats `p`, `a`, and `b` the same way. It is not very useful. How caller can do anything with these arguments if they all have different semantics? `p` must always be possitional, `a` can be both, `b` can only be keyword argument.\r\n\r\nI propose adding `inspect.signature` support for `frame` objects and use it.\r\nFor example, adding to `Signature` class\r\n\r\n```python\r\n@classmethod\r\ndef from_frame(cls, frame): ...\r\n```\r\n\r\nwill provide a new API to do the same thing, but correctly.","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2023-08-10T08:50:26Z","url":"https://github.com/python/cpython/issues/107833"}
| 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:e3531970-3266-244e-f3fd-3a950a292d5e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E530:6365:381EEAD:4ACC2D4:6B021B75 |
| html-safe-nonce | 5d74258aeddebe0eadda021ea936a3c438623e11b384c290992dc440ddae2dea |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTMwOjYzNjU6MzgxRUVBRDo0QUNDMkQ0OjZCMDIxQjc1IiwidmlzaXRvcl9pZCI6IjUyMTE1NTgyODI3NzQzMjIwMzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ee899c49f082cc732d4a64d5ab087f491fb973995182f648c6ebc590d4c87ffb |
| hovercard-subject-tag | issue:1844716244 |
| 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/107833/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b00c6d48203dd2b6178057ba20f39e7f16aea36ba99616b0e2b3ae382e112d03/python/cpython/issues/107833 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b00c6d48203dd2b6178057ba20f39e7f16aea36ba99616b0e2b3ae382e112d03/python/cpython/issues/107833 |
| og:image:alt | Here's an example: >>> fr = None >>> def a(p, /, a, *, b): ... global fr ... fr = inspect.currentframe() ... >>> a(1, 2, b=3) >>> fr ', line 3, code a> >>> inspe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sobolevn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width