Title: gh-105080: Fixed inconsistent signature on derived classes by gaogaotiantian · Pull Request #105217 · python/cpython · GitHub
Open Graph Title: gh-105080: Fixed inconsistent signature on derived classes by gaogaotiantian · Pull Request #105217 · python/cpython
X Title: gh-105080: Fixed inconsistent signature on derived classes by gaogaotiantian · Pull Request #105217 · python/cpython
Description: class B: def __new__(self, *args, **kwargs): return super().__new__(self) def __init__(self, value): self.value = value class D1(B): def __init__(self, value): super().__init__(value) class D2(D1): pass For the code above, inspect.signature(D2) will give a different result than inspect.signature(D1), which is counter-intuitive. This also affects help(D2) vs help(D1). We should keep the consistency for the signatures for derived classes (of course when the signature is not changed). This is due to a corner case in inspect.signature() where only the direct defined __init__ and __new__ method on the class takes priority, then __new__ is always used if defined on any base classes. This fix searches __new__ and __init__ based on MRO and prioritize __new__ if both are defined on a base class. Issue: gh-105080
Open Graph Description: class B: def __new__(self, *args, **kwargs): return super().__new__(self) def __init__(self, value): self.value = value class D1(B): def __init__(self, value): ...
X Description: class B: def __new__(self, *args, **kwargs): return super().__new__(self) def __init__(self, value): self.value = value class D1(B): def __init__(self, value): ...
Opengraph URL: https://github.com/python/cpython/pull/105217
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:fd830127-f44b-67c7-032e-48ce6881e983 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9270:23D843:E0BBC:12964B:6969B6B4 |
| html-safe-nonce | 3aa7236d2c479ce90ac7226b045756369aaa306ee019d3fdfb877dc898329e8e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MjcwOjIzRDg0MzpFMEJCQzoxMjk2NEI6Njk2OUI2QjQiLCJ2aXNpdG9yX2lkIjoiOTAxNTAwMDU2NjM4NjUwNTM5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9ee9b6f1e8c0a55ef1cc815c2dc06e5e642d6c0ffb8d04765231a2fb0974c5b4 |
| hovercard-subject-tag | pull_request:1375028309 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/105217/files |
| twitter:image | https://avatars.githubusercontent.com/u/13121107?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/13121107?s=400&v=4 |
| og:image:alt | class B: def __new__(self, *args, **kwargs): return super().__new__(self) def __init__(self, value): self.value = value class D1(B): def __init__(self, value): ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | acedec8b5f975d9e3d494ddd8f949b0b8a0de59d393901e26f73df9dcba80056 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 83c08c21cdda978090dc44364b71aa5bc6dcea79 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width