Title: Resolve number slots via MRO in PyNumber and operator, ensure inherit… by YashSuthar983 · Pull Request #6222 · RustPython/RustPython · GitHub
Open Graph Title: Resolve number slots via MRO in PyNumber and operator, ensure inherit… by YashSuthar983 · Pull Request #6222 · RustPython/RustPython
X Title: Resolve number slots via MRO in PyNumber and operator, ensure inherit… by YashSuthar983 · Pull Request #6222 · RustPython/RustPython
Description: …ed and dynamically added methods are found.
Use class().mro_find_map() to mimic the same behaviour as CPython.
issue: #5726
test Cases
dynamic_patch_test
# Expected behavior: After patching A.__mul__ at runtime, B() * 2 should succeed.
class A:
pass
class B(A):
pass
b = B()
def mul(self, other):
return ("mul", type(self).__name__, other)
A.__mul__ = mul
res = b * 2
assert res == ("mul", "B", 2)
print("dynamic_patch OK")
Cpython
Bravo:~$ python3 ../number_mro_dynamic_patch.py
dynamic_patch OK
RustPython
Bravo:~/contri/RustPython$ cargo run --quiet -- tests/number_mro_dynamic_patch.py
Traceback (most recent call last):
File "tests/number_mro_dynamic_patch.py", line 20, in
Open Graph Description: …ed and dynamically added methods are found. Use class().mro_find_map() to mimic the same behaviour as CPython. issue: #5726 test Cases dynamic_patch_test # Expected behavior: After patching A.__mu...
X Description: …ed and dynamically added methods are found. Use class().mro_find_map() to mimic the same behaviour as CPython. issue: #5726 test Cases dynamic_patch_test # Expected behavior: After patching A.__mu...
Opengraph URL: https://github.com/RustPython/RustPython/pull/6222
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:882112a4-e17e-ff3a-11dd-5cddf5466580 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9C70:20812F:7427A:93AD4:696AFBDB |
| html-safe-nonce | 6e105ed27cdda5ea8e295ecbfb764d102c80aba18df4d7c2b8f981e2a6288ea2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QzcwOjIwODEyRjo3NDI3QTo5M0FENDo2OTZBRkJEQiIsInZpc2l0b3JfaWQiOiI4MjU3NDE0MjAxMzI3OTQyNjE5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3779e403c506ac81691cd3f98efb3a350f2d705670909165fc3167fbe1a5cdbe |
| hovercard-subject-tag | pull_request:2951820741 |
| 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/RustPython/RustPython/pull/6222/files |
| twitter:image | https://avatars.githubusercontent.com/u/183753953?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/183753953?s=400&v=4 |
| og:image:alt | …ed and dynamically added methods are found. Use class().mro_find_map() to mimic the same behaviour as CPython. issue: #5726 test Cases dynamic_patch_test # Expected behavior: After patching A.__mu... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width