Comparisons aren't valid in relativedelta
Bug #969928 reported by
Ewan Higgs
This bug affects 2 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dateutil |
New
|
Undecided
|
Unassigned |
Bug Description
This bug has two parts
1. relativedelta.
2. There is no comparison magic function in relativedelta which makes some comparisons return nonsense. e.g.
In [1]: import dateutil.
In [2]: r.relativedelta
Out[2]: True
The __cmp__ I've submitted in the patch doesn't deal with the year/month/day/etc because I think it requires some discussion on what needs to be implemented there. But certainly 2 years > 1 years should be obviously correct.
To post a comment you must log in.
Yeah, it is tricky... Which is greater, 29 days, or 1 month? I'm not sure if it makes sense to implement a partial solution, something that checks only days for example, as that can incorrectly imply that all cases are covered. In Python 3 when the comparisons are not implemented, the operation raises an exception. I'm inclined to just put magic functions that also raise NotImplemented, so that the functionality is equal.
In any case if/when a sensible solution is found, it needs to be implemented with rich comparisons, not with __cmp__ (it's not supported in Python 3).