@@ -2710,6 +2710,9 @@ def __add__(self, other):
2710
2710
return self .apply (other )
2711
2711
except ApplyTypeError :
2712
2712
return NotImplemented
2713
+ except OverflowError :
2714
+ raise OverflowError ("the add operation between {} and {} "
2715
+ "will overflow" .format (self , other ))
2713
2716
2714
2717
def __eq__ (self , other ):
2715
2718
if isinstance (other , compat .string_types ):
@@ -2748,14 +2751,26 @@ def nanos(self):
2748
2751
2749
2752
def apply (self , other ):
2750
2753
# Timestamp can handle tz and nano sec, thus no need to use apply_wraps
2751
- if isinstance (other , (datetime , np .datetime64 , date )):
2754
+ if isinstance (other , Timestamp ):
2755
+
2756
+ # GH 15126
2757
+ # in order to avoid a recursive
2758
+ # call of __add__ and __radd__ if there is
2759
+ # an exception, when we call using the + operator,
2760
+ # we directly call the known method
2761
+ result = other .__add__ (self )
2762
+ if result == NotImplemented :
2763
+ raise OverflowError
2764
+ return result
2765
+ elif isinstance (other , (datetime , np .datetime64 , date )):
2752
2766
return as_timestamp (other ) + self
2767
+
2753
2768
if isinstance (other , timedelta ):
2754
2769
return other + self .delta
2755
2770
elif isinstance (other , type (self )):
2756
2771
return type (self )(self .n + other .n )
2757
- else :
2758
- raise ApplyTypeError ('Unhandled type: %s' % type (other ).__name__ )
2772
+
2773
+ raise ApplyTypeError ('Unhandled type: %s' % type (other ).__name__ )
2759
2774
2760
2775
_prefix = 'undefined'
2761
2776
0 commit comments