[Python-checkins] python/dist/src/Modules datetimemodule.c,1.15,1.16
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Thu, 26 Dec 2002 16:41:13 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv11885/python/Modules
Modified Files:
datetimemodule.c
Log Message:
Make comparison and subtraction of aware objects ignore tzinfo if the
operands have identical tzinfo members (meaning object identity -- "is").
I misunderstood the intent here, reading wrong conclusion into
conflicting clues.
Index: datetimemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/datetimemodule.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** datetimemodule.c 25 Dec 2002 07:40:55 -0000 1.15
--- datetimemodule.c 27 Dec 2002 00:41:11 -0000 1.16
***************
*** 3137,3151 ****
return NULL;
}
! n1 = classify_utcoffset((PyObject *)self, &offset1);
! assert(n1 != OFFSET_UNKNOWN);
! if (n1 == OFFSET_ERROR)
! return NULL;
!
! n2 = classify_utcoffset(other, &offset2);
! assert(n2 != OFFSET_UNKNOWN);
! if (n2 == OFFSET_ERROR)
! return NULL;
! /* If they're both naive, or both aware and have the same offsets,
* we get off cheap. Note that if they're both naive, offset1 ==
* offset2 == 0 at this point.
--- 3137,3162 ----
return NULL;
}
! /* Ignore utcoffsets if they have identical tzinfo members. This
! * isn't an optimization, it's design. If utcoffset() doesn't ignore
! * its argument, it may return different results for self and other
! * even if they have identical tzinfo members, and we're deliberately
! * suppressing that (possible) difference.
! */
! if (get_tzinfo_member((PyObject *)self) == get_tzinfo_member(other)) {
! offset1 = offset2 = 0;
! n1 = n2 = OFFSET_NAIVE;
! }
! else {
! n1 = classify_utcoffset((PyObject *)self, &offset1);
! assert(n1 != OFFSET_UNKNOWN);
! if (n1 == OFFSET_ERROR)
! return NULL;
! n2 = classify_utcoffset(other, &offset2);
! assert(n2 != OFFSET_UNKNOWN);
! if (n2 == OFFSET_ERROR)
! return NULL;
! }
! /* If they're both naive, or both aware and have the same offsets,
* we get off cheap. Note that if they're both naive, offset1 ==
* offset2 == 0 at this point.
***************
*** 3657,3669 ****
return NULL;
}
! n1 = classify_utcoffset((PyObject *)self, &offset1);
! assert(n1 != OFFSET_UNKNOWN);
! if (n1 == OFFSET_ERROR)
! return NULL;
! n2 = classify_utcoffset(other, &offset2);
! assert(n2 != OFFSET_UNKNOWN);
! if (n2 == OFFSET_ERROR)
! return NULL;
/* If they're both naive, or both aware and have the same offsets,
--- 3668,3692 ----
return NULL;
}
! /* Ignore utcoffsets if they have identical tzinfo members. This
! * isn't an optimization, it's design. If utcoffset() doesn't ignore
! * its argument, it may return different results for self and other
! * even if they have identical tzinfo members, and we're deliberately
! * suppressing that (possible) difference.
! */
! if (get_tzinfo_member((PyObject *)self) == get_tzinfo_member(other)) {
! offset1 = offset2 = 0;
! n1 = n2 = OFFSET_NAIVE;
! }
! else {
! n1 = classify_utcoffset((PyObject *)self, &offset1);
! assert(n1 != OFFSET_UNKNOWN);
! if (n1 == OFFSET_ERROR)
! return NULL;
! n2 = classify_utcoffset(other, &offset2);
! assert(n2 != OFFSET_UNKNOWN);
! if (n2 == OFFSET_ERROR)
! return NULL;
! }
/* If they're both naive, or both aware and have the same offsets,
***************
*** 4602,4614 ****
PyDateTime_Delta *delta;
! n1 = classify_utcoffset(left, &offset1);
! assert(n1 != OFFSET_UNKNOWN);
! if (n1 == OFFSET_ERROR)
! return NULL;
! n2 = classify_utcoffset(right, &offset2);
! assert(n2 != OFFSET_UNKNOWN);
! if (n2 == OFFSET_ERROR)
! return NULL;
if (n1 != n2) {
--- 4625,4651 ----
PyDateTime_Delta *delta;
! /* Ignore utcoffsets if they have identical tzinfo
! * members. This isn't an optimization, it's design.
! * If utcoffset() doesn't ignore its argument, it may
! * return different results for self and other even
! * if they have identical tzinfo members, and we're
! * deliberately suppressing that (possible) difference.
! */
! if (get_tzinfo_member(left) ==
! get_tzinfo_member(right)) {
! offset1 = offset2 = 0;
! n1 = n2 = OFFSET_NAIVE;
! }
! else {
! n1 = classify_utcoffset(left, &offset1);
! assert(n1 != OFFSET_UNKNOWN);
! if (n1 == OFFSET_ERROR)
! return NULL;
! n2 = classify_utcoffset(right, &offset2);
! assert(n2 != OFFSET_UNKNOWN);
! if (n2 == OFFSET_ERROR)
! return NULL;
! }
if (n1 != n2) {