diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index c166edf35946c..1fba963496ba7 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -324,7 +324,7 @@ cdef class _Timestamp(ABCTimestamp): elif other is NaT: return op == Py_NE elif is_datetime64_object(other): - ots = _Timestamp._from_dt64(other) + ots = Timestamp(other) elif PyDateTime_Check(other): if self.nanosecond == 0: val = self.to_pydatetime() diff --git a/pandas/tests/scalar/timestamp/test_comparisons.py b/pandas/tests/scalar/timestamp/test_comparisons.py index b5084e7a8925e..510c29bd3893d 100644 --- a/pandas/tests/scalar/timestamp/test_comparisons.py +++ b/pandas/tests/scalar/timestamp/test_comparisons.py @@ -12,6 +12,13 @@ class TestTimestampComparison: + def test_compare_non_nano_dt64(self): + # don't raise when converting dt64 to Timestamp in __richcmp__ + dt = np.datetime64("1066-10-14") + ts = Timestamp(dt) + + assert dt == ts + def test_comparison_dt64_ndarray(self): ts = Timestamp("2021-01-01") ts2 = Timestamp("2019-04-05")