[issue15973] Segmentation fault on timezone comparison

Alexander Belopolsky report at bugs.python.org
Thu Sep 20 03:48:09 CEST 2012


Alexander Belopolsky added the comment:

I think the following simple patch should do the trick.  I'll add some tests and commit.  Should this get in 3.3.0? 


diff -r 19c74cadea95 Modules/_datetimemodule.c
--- a/Modules/_datetimemodule.c	Wed Sep 19 08:25:01 2012 +0300
+++ b/Modules/_datetimemodule.c	Wed Sep 19 21:42:51 2012 -0400
@@ -3215,6 +3215,11 @@
 {
     if (op != Py_EQ && op != Py_NE)
         Py_RETURN_NOTIMPLEMENTED;
+    if (Py_TYPE(other) != &PyDateTime_TimeZoneType)
+	if (op == Py_EQ)
+	    Py_RETURN_FALSE;
+	else
+	    Py_RETURN_TRUE;
     return delta_richcompare(self->offset, other->offset, op);
 }

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15973>
_______________________________________


More information about the Python-bugs-list mailing list