Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(32767)

Side by Side Diff: Modules/_datetimemodule.c

Issue 29140: time_hash() reads the wrong bytes to get microseconds
Patch Set: Created 2 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* C implementation for the date/time type documented at 1 /* C implementation for the date/time type documented at
2 * http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage 2 * http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage
3 */ 3 */
4 4
5 #include "Python.h" 5 #include "Python.h"
6 #include "structmember.h" 6 #include "structmember.h"
7 7
8 #include <time.h> 8 #include <time.h>
9 9
10 #ifdef MS_WINDOWS 10 #ifdef MS_WINDOWS
(...skipping 3825 matching lines...) Expand 10 before | Expand all | Expand 10 after
3836 Py_DECREF(offset1); 3836 Py_DECREF(offset1);
3837 Py_XDECREF(offset2); 3837 Py_XDECREF(offset2);
3838 return result; 3838 return result;
3839 } 3839 }
3840 3840
3841 static Py_hash_t 3841 static Py_hash_t
3842 time_hash(PyDateTime_Time *self) 3842 time_hash(PyDateTime_Time *self)
3843 { 3843 {
3844 if (self->hashcode == -1) { 3844 if (self->hashcode == -1) {
3845 PyObject *offset, *self0; 3845 PyObject *offset, *self0;
3846 if (DATE_GET_FOLD(self)) { 3846 if (TIME_GET_FOLD(self)) {
3847 self0 = new_time_ex2(DATE_GET_HOUR(self), 3847 self0 = new_time_ex2(TIME_GET_HOUR(self),
3848 DATE_GET_MINUTE(self), 3848 TIME_GET_MINUTE(self),
3849 DATE_GET_SECOND(self), 3849 TIME_GET_SECOND(self),
3850 DATE_GET_MICROSECOND(self), 3850 TIME_GET_MICROSECOND(self),
3851 HASTZINFO(self) ? self->tzinfo : Py_None, 3851 HASTZINFO(self) ? self->tzinfo : Py_None,
3852 0, Py_TYPE(self)); 3852 0, Py_TYPE(self));
3853 if (self0 == NULL) 3853 if (self0 == NULL)
3854 return -1; 3854 return -1;
3855 } 3855 }
3856 else { 3856 else {
3857 self0 = (PyObject *)self; 3857 self0 = (PyObject *)self;
3858 Py_INCREF(self0); 3858 Py_INCREF(self0);
3859 } 3859 }
3860 offset = time_utcoffset(self0, NULL); 3860 offset = time_utcoffset(self0, NULL);
(...skipping 2157 matching lines...) Expand 10 before | Expand all | Expand 10 after
6018 enough to say. 6018 enough to say.
6019 6019
6020 In any case, it's clear that the default fromutc() is strong enough to handle 6020 In any case, it's clear that the default fromutc() is strong enough to handle
6021 "almost all" time zones: so long as the standard offset is invariant, it 6021 "almost all" time zones: so long as the standard offset is invariant, it
6022 doesn't matter if daylight time transition points change from year to year, or 6022 doesn't matter if daylight time transition points change from year to year, or
6023 if daylight time is skipped in some years; it doesn't matter how large or 6023 if daylight time is skipped in some years; it doesn't matter how large or
6024 small dst() may get within its bounds; and it doesn't even matter if some 6024 small dst() may get within its bounds; and it doesn't even matter if some
6025 perverse time zone returns a negative dst()). So a breaking case must be 6025 perverse time zone returns a negative dst()). So a breaking case must be
6026 pretty bizarre, and a tzinfo subclass can override fromutc() if it is. 6026 pretty bizarre, and a tzinfo subclass can override fromutc() if it is.
6027 --------------------------------------------------------------------------- */ 6027 --------------------------------------------------------------------------- */
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+