File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -1498,12 +1498,14 @@ def __rsub__(self, other):
1498
1498
from pandas .core .arrays import DatetimeArray
1499
1499
1500
1500
datetime_result = self - other
1501
- if isinstance (datetime_result , DatetimeArray ):
1502
- raise TypeError (
1503
- "TypeError: unsupported operand type(s) for -: "
1504
- f"'{ type (self ).__name__ } ' and '{ type (other ).__name__ } '"
1505
- )
1506
- return - (datetime_result )
1501
+ try :
1502
+ return - (datetime_result )
1503
+ except TypeError as e :
1504
+ if isinstance (datetime_result , DatetimeArray ):
1505
+ raise TypeError (
1506
+ "Unsupported operand type(s) for -: "
1507
+ f"'{ type (self ).__name__ } ' and '{ type (other ).__name__ } '"
1508
+ ) from e
1507
1509
1508
1510
def __iadd__ (self , other ) -> Self :
1509
1511
result = self + other
You can’t perform that action at this time.
0 commit comments