-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix rich comparisons for datetime objects #53
Conversation
…ch comparison to work
The python 2.7 Travis tests are failing. We can't merge until this is fixed. |
This was alluded to in the description and I am still trying to work out the best way of dealing with it. At present the only way I have is to add
This solves the original problem for Python 3 and allows the code to behave as before for Python 2, but in Python 2 code the original problem will still exist. As far as I can tell there is no way in Python 2 to separate objects that should be comparable to cftime.datatime objects and those that shouldn't be without being explicit (e.g. the way datetime objects are handled), or prescribing a structure on those objects that want to be comparable. Would this be acceptable? |
…ixes the problem for Python3 but leaves the problem for Python2.
I'm OK with this. @jhamman? |
I'm also fine with this but would appreciate a test to validate the expected behavior. |
I can merge this as soon as a test is added |
I'm going to go ahead and merge this, without a test for now. |
As identified in #11, rich comparisons for
cftime.datetime
objects with other unknown objects do not work as cftime raises aTypeError
instead of returningNotImplemented
. This pull request is to fix this.While this works in Python 3, it should be noted that Python 2 is more problematic. The unit test
not_comparable_4
intest_richcmp
will fail ascftime.datetime
objects are treated as comparable with integer zero and so theTypeError
is not raised when it is expected.