Title: [3.11] gh-85267: Improvements to inspect.signature __text_signature__ handling (GH-98796) by hauntsaninja · Pull Request #100392 · python/cpython · GitHub
Open Graph Title: [3.11] gh-85267: Improvements to inspect.signature __text_signature__ handling (GH-98796) by hauntsaninja · Pull Request #100392 · python/cpython
X Title: [3.11] gh-85267: Improvements to inspect.signature __text_signature__ handling (GH-98796) by hauntsaninja · Pull Request #100392 · python/cpython
Description: This makes a couple related changes to inspect.signature's behaviour when parsing a signature from __text_signature__. First, inspect.signature is documented as only raising ValueError or TypeError. However, in some cases, we could raise RuntimeError. This PR changes that, thereby fixing GH-83685. (Note that the new ValueErrors in RewriteSymbolics are caught and then reraised with a message) Second, inspect.signature could randomly drop parameters that it didn't understand (corresponding to return None in the p function). This is the core issue in GH-85267. I think this is very surprising behaviour and it seems better to fail outright. Third, adding this new failure broke a couple tests. To fix them (and to e.g. allow inspect.signature(select.epoll.register) as in GH-85267), I add constant folding of a couple binary operations to RewriteSymbolics. (There's some discussion of making signature expression evaluation arbitrary powerful in GH-68155. I think that's out of scope. The additional constant folding here is pretty straightforward, useful, and not much of a slippery slope) Fourth, while GH-85267 is incorrect about the cause of the issue, it turns out if you had consecutive newlines in text_signature, you'd get tokenize.TokenError. Finally, the if name is invalid: code path was dead, since parse_name never returned invalid.. (cherry picked from commit 79311cb) Co-authored-by: Shantanu 12621235+hauntsaninja@users.noreply.github.com
Open Graph Description: This makes a couple related changes to inspect.signature's behaviour when parsing a signature from __text_signature__. First, inspect.signature is documented as only raising ValueError or TypeE...
X Description: This makes a couple related changes to inspect.signature's behaviour when parsing a signature from __text_signature__. First, inspect.signature is documented as only raising ValueError or T...
Opengraph URL: https://github.com/python/cpython/pull/100392
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:23628f25-ae6c-0aa2-6459-2e27648bd6db |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | CE3A:10FD0C:CE8DB:11B0B4:6969632B |
| html-safe-nonce | a42a0b85b9e6c2dbcc455346113af24a2eceb168765e80e28a7c951e8f7aec59 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTNBOjEwRkQwQzpDRThEQjoxMUIwQjQ6Njk2OTYzMkIiLCJ2aXNpdG9yX2lkIjoiNTA1OTYwMTQ4NTExNjU2NDI2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d0119dde0a3e5fa269d5e88d2e3dd089545da8d203681ffbc740b2e2be7ecfdf |
| hovercard-subject-tag | pull_request:1173136153 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,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/python/cpython/pull/100392/checks |
| twitter:image | https://avatars.githubusercontent.com/u/12621235?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/12621235?s=400&v=4 |
| og:image:alt | This makes a couple related changes to inspect.signature's behaviour when parsing a signature from __text_signature__. First, inspect.signature is documented as only raising ValueError or TypeE... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 48487c1ad776a7975b7132d95f4240ff3ae37cd5b8e3cb597102a4edb76738f1 |
| 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 full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 669463fcc54773a88c1f5a44eef6b99a5504b9c7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width