@@ -475,11 +475,10 @@ cdef class _Timestamp(datetime):
475
475
int64_t value, nanosecond
476
476
object offset # frequency reference
477
477
478
- def __hash__ (self ):
478
+ def __hash__ (_Timestamp self ):
479
479
if self .nanosecond:
480
480
return hash (self .value)
481
- else :
482
- return datetime.__hash__ (self )
481
+ return datetime.__hash__ (self )
483
482
484
483
def __richcmp__ (_Timestamp self , object other , int op ):
485
484
cdef:
@@ -520,13 +519,14 @@ cdef class _Timestamp(datetime):
520
519
self ._assert_tzawareness_compat(other)
521
520
return _cmp_scalar(self .value, ots.value, op)
522
521
523
- cdef _compare_outside_nanorange(self , object other, int op):
522
+ cdef bint _compare_outside_nanorange(_Timestamp self , datetime other,
523
+ int op) except - 1 :
524
524
cdef datetime dtval = self .to_datetime()
525
525
526
526
self ._assert_tzawareness_compat(other)
527
527
528
528
if self .nanosecond == 0 :
529
- return PyObject_RichCompare (dtval, other, op)
529
+ return PyObject_RichCompareBool (dtval, other, op)
530
530
else :
531
531
if op == Py_EQ:
532
532
return False
@@ -541,15 +541,15 @@ cdef class _Timestamp(datetime):
541
541
elif op == Py_GE:
542
542
return dtval >= other
543
543
544
- cdef _assert_tzawareness_compat(self , object other):
544
+ cdef void _assert_tzawareness_compat(_Timestamp self , object other):
545
545
if self .tzinfo is None :
546
546
if other.tzinfo is not None :
547
- raise Exception (' Cannot compare tz-naive and '
548
- ' tz-aware timestamps' )
547
+ raise ValueError (' Cannot compare tz-naive and tz-aware '
548
+ ' timestamps' )
549
549
elif other.tzinfo is None :
550
- raise Exception (' Cannot compare tz-naive and tz-aware timestamps' )
550
+ raise ValueError (' Cannot compare tz-naive and tz-aware timestamps' )
551
551
552
- cpdef to_datetime(self ):
552
+ cpdef datetime to_datetime(_Timestamp self ):
553
553
cdef:
554
554
pandas_datetimestruct dts
555
555
_TSObject ts
0 commit comments