]> granicus.if.org Git - python/commitdiff
Issue #29140: Fix hash(datetime.time)
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 3 Jan 2017 22:47:12 +0000 (23:47 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 3 Jan 2017 22:47:12 +0000 (23:47 +0100)
Fix time_hash() function: replace DATE_xxx() macros with TIME_xxx() macros.
Before, the hash function used a wrong value for microseconds if fold is set
(equal to 1).

Modules/_datetimemodule.c

index c09cce9da725aaa80731085e9e372359a0640e71..291920dc0fa32f18f6bc0b2e6d5a0841a079ea37 100644 (file)
@@ -3843,11 +3843,11 @@ time_hash(PyDateTime_Time *self)
 {
     if (self->hashcode == -1) {
         PyObject *offset, *self0;
-        if (DATE_GET_FOLD(self)) {
-            self0 = new_time_ex2(DATE_GET_HOUR(self),
-                                 DATE_GET_MINUTE(self),
-                                 DATE_GET_SECOND(self),
-                                 DATE_GET_MICROSECOND(self),
+        if (TIME_GET_FOLD(self)) {
+            self0 = new_time_ex2(TIME_GET_HOUR(self),
+                                 TIME_GET_MINUTE(self),
+                                 TIME_GET_SECOND(self),
+                                 TIME_GET_MICROSECOND(self),
                                  HASTZINFO(self) ? self->tzinfo : Py_None,
                                  0, Py_TYPE(self));
             if (self0 == NULL)