classification
Title: None-datetime comparison doesn't work
Type: enhancement Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: jribbens, tim.peters
Priority: normal Keywords:

Created on 2007-03-04 11:52 by jribbens, last changed 2007-03-04 18:48 by tim.peters. This issue is now closed.

Messages (2)
msg31421 - (view) Author: Jon Ribbens (jribbens) Date: 2007-03-04 11:52
Comparing None to the objects in the datetime module throws an exception. This violates the general rule in Python that None compares "less than" everything else.
msg31422 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2007-03-04 18:48
There is no such rule, and it's quite deliberate that the newer types (like datetime objects and sets) raise an exception on mixed-type inequality comparisons.  For older types, the result of inequality comparison with None isn't defined by the language, and the outcome does vary across CPython releases.

Rejecting this, since the code is working as designed and documented (see, e.g., footnote (4) in the datetime docs:  "Note: In order to stop comparison from falling back to the default scheme of comparing object addresses, datetime comparison normally raises TypeError if the other comparand isn't also a datetime object. However, ...").
History
Date User Action Args
2007-03-04 11:52:42jribbenscreate