Title: Conflation of NotImplemented and NotImplementedError · Issue #419 · RustPython/RustPython · GitHub
Open Graph Title: Conflation of NotImplemented and NotImplementedError · Issue #419 · RustPython/RustPython
X Title: Conflation of NotImplemented and NotImplementedError · Issue #419 · RustPython/RustPython
Description: The contract for binary methods such as __add__, __eq__, etc. is such that they are expected to return NotImplemented error to signal lack of support for a particular type, in which case the interpreter will try flipping the operands, an...
Open Graph Description: The contract for binary methods such as __add__, __eq__, etc. is such that they are expected to return NotImplemented error to signal lack of support for a particular type, in which case the interp...
X Description: The contract for binary methods such as __add__, __eq__, etc. is such that they are expected to return NotImplemented error to signal lack of support for a particular type, in which case the interp...
Opengraph URL: https://github.com/RustPython/RustPython/issues/419
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Conflation of NotImplemented and NotImplementedError","articleBody":"The contract for binary methods such as `__add__`, `__eq__`, etc. is such that they are expected to return `NotImplemented` error to signal lack of support for a particular type, in which case the interpreter will try flipping the operands, and finally fall back to object comparison (in the case of `==`).\r\n\r\nI believe that `VirtualMachine::call_or_unsupported` is `RustPython`'s implementation of this behavior, but instead of using the `NotImplemented` built-in constant, it expects implementors to raise a `NotImplementedError`. This can be seen by calling the magic methods directly:\r\n\r\nRustPython:\r\n```\r\n\u003e\u003e\u003e\u003e\u003e (3).__sub__('')\r\nTraceback (most recent call last):\r\n File \u003cunknown\u003e, line 0, in \u003cmodule\u003e\r\nNotImplementedError: Cannot substract 'int' object and 'str' object\r\n```\r\n\r\nCPython:\r\n```\r\n\u003e\u003e\u003e (3).__sub__('')\r\nNotImplemented\r\n```\r\n\r\nThis was discovered in #410.","author":{"url":"https://github.com/OddCoincidence","@type":"Person","name":"OddCoincidence"},"datePublished":"2019-02-09T18:16:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/419/RustPython/issues/419"}
| 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:0b4a9905-547f-f226-9314-5129565f01fc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E746:374DCF:7E39F6:A8D281:6A598C73 |
| html-safe-nonce | 09843f62d09978a0e02eca91b7afd10aaa0e9c66296c9888c748bf6d4a896f30 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzQ2OjM3NERDRjo3RTM5RjY6QThEMjgxOjZBNTk4QzczIiwidmlzaXRvcl9pZCI6Ijg3NDg0NDE2OTMyODI5OTUzMTUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4281d03d686b63214db1dd6897b34452eecfc99b4b01abc7304b7de8fc3c1ff2 |
| hovercard-subject-tag | issue:408456083 |
| 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/RustPython/RustPython/419/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0a95594397657f6d95eaaa422e6de28497f33ffbf96870e361786c04f735e6a9/RustPython/RustPython/issues/419 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0a95594397657f6d95eaaa422e6de28497f33ffbf96870e361786c04f735e6a9/RustPython/RustPython/issues/419 |
| og:image:alt | The contract for binary methods such as __add__, __eq__, etc. is such that they are expected to return NotImplemented error to signal lack of support for a particular type, in which case the interp... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | OddCoincidence |
| hostname | github.com |
| expected-hostname | github.com |
| None | a540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5 |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 624bb50a7497aa346bef8cc3743af408a9ea10ca |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width