Index: datetimemodule.c =================================================================== --- datetimemodule.c (revision 62827) +++ datetimemodule.c (working copy) @@ -1756,6 +1756,9 @@ else if (op == Py_EQ || op == Py_NE) diff = 1; /* any non-zero value will do */ + else if (other == Py_None) + diff = -1; /* None value will do */ + else /* stop this from falling back to address comparison */ return cmperror((PyObject *)self, other); @@ -2578,6 +2581,9 @@ else if (op == Py_EQ || op == Py_NE) diff = 1; /* any non-zero value will do */ + else if (other == Py_None) + diff = -1; /* None value will do */ + else /* stop this from falling back to address comparison */ return cmperror((PyObject *)self, other); @@ -3298,6 +3304,10 @@ int offset1, offset2; if (! PyTime_Check(other)) { + + if (other == Py_None) + return diff_to_bool(-1, op); /* None value will do */ + if (op == Py_EQ || op == Py_NE) { PyObject *result = op == Py_EQ ? Py_False : Py_True; Py_INCREF(result); @@ -4236,6 +4246,9 @@ * (it's the more specific subtype). So we can stop that * combination here reliably. */ + if (other == Py_None) + return diff_to_bool(-1, op); /* None value will do */ + if (PyObject_HasAttrString(other, "timetuple") && ! PyDate_Check(other)) { /* A hook for other kinds of datetime objects. */