AlenkaF commented on PR #49845: URL: https://github.com/apache/arrow/pull/49845#issuecomment-5711406360
OK, looking at the error more closely the behavior is actually correct. We are fixing two things with this PR: 1. Returning an operation result if operation from left gives `NotImplemented` but operation from the right gives a result. 2. Falling back to Python when operation from left and from the right return `NotImplemented`. When a class has `__radd__` implemented we should not get `TypeError` raised by our compute module (which is what changed and is a regression we need to fix). This is corrected with this PR as running the operation from left will result in `NotImplemented` and then Python will try the operation from the right. When even the operation from the right side returns `NotImplemented` (when, for example, `__radd__` is not implemented), then Python will fallback to `TypeError: unsupported operand type(s)`. This is not the same `TypeError` returned previously iwhen the error was returned by our compute module. See note in https://docs.python.org/3/builtins/constants.html#NotImplemented > ... When a binary (or in-place) method returns NotImplemented the interpreter will try the reflected operation on the other type (or some other fallback, depending on the operator). If all attempts return NotImplemented, the interpreter will raise an appropriate exception. I will add a comment to the tests to make this explicit. cc @raulcd -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
