@@ -87,7 +87,7 @@ cdef class _Timestamp(datetime):
8787 return PyObject_RichCompareBool(val, other, op)
8888
8989 try :
90- ots = self . __class__ (other)
90+ ots = type ( self ) (other)
9191 except ValueError :
9292 return self ._compare_outside_nanorange(other, op)
9393 else :
@@ -96,7 +96,7 @@ cdef class _Timestamp(datetime):
9696 if ndim != - 1 :
9797 if ndim == 0 :
9898 if is_datetime64_object(other):
99- other = self . __class__ (other)
99+ other = type ( self ) (other)
100100 elif is_array(other):
101101 # zero-dim array, occurs if try comparison with
102102 # datetime64 scalar on the left hand side
@@ -105,7 +105,7 @@ cdef class _Timestamp(datetime):
105105 # the numpy C api to extract it.
106106 other = cnp.PyArray_ToScalar(cnp.PyArray_DATA(other),
107107 other)
108- other = self . __class__ (other)
108+ other = type ( self ) (other)
109109 else :
110110 return NotImplemented
111111 elif is_array(other):
@@ -226,8 +226,7 @@ cdef class _Timestamp(datetime):
226226
227227 if is_timedelta64_object(other):
228228 other_int = other.astype(' timedelta64[ns]' ).view(' i8' )
229- return self .__class__ (self .value + other_int,
230- tz = self .tzinfo, freq = self .freq)
229+ return type (self )(self .value + other_int, tz = self .tzinfo, freq = self .freq)
231230
232231 elif is_integer_object(other):
233232 maybe_integer_op_deprecated(self )
@@ -238,8 +237,7 @@ cdef class _Timestamp(datetime):
238237 elif self .freq is None :
239238 raise NullFrequencyError(
240239 " Cannot add integral value to Timestamp without freq." )
241- return self .__class__ ((self .freq * other).apply(self ),
242- freq = self .freq)
240+ return type (self )((self .freq * other).apply(self ), freq = self .freq)
243241
244242 elif PyDelta_Check(other) or hasattr (other, ' delta' ):
245243 # delta --> offsets.Tick
@@ -253,8 +251,7 @@ cdef class _Timestamp(datetime):
253251 other.seconds * 1000000 +
254252 other.microseconds) * 1000
255253
256- result = self .__class__ (self .value + nanos,
257- tz = self .tzinfo, freq = self .freq)
254+ result = type (self )(self .value + nanos, tz = self .tzinfo, freq = self .freq)
258255 return result
259256
260257 elif is_array(other):
@@ -272,7 +269,7 @@ cdef class _Timestamp(datetime):
272269
273270 result = datetime.__add__ (self , other)
274271 if PyDateTime_Check(result):
275- result = self . __class__ (result)
272+ result = type ( self ) (result)
276273 result.nanosecond = self .nanosecond
277274 return result
278275
@@ -304,9 +301,9 @@ cdef class _Timestamp(datetime):
304301 if (PyDateTime_Check(self )
305302 and (PyDateTime_Check(other) or is_datetime64_object(other))):
306303 if isinstance (self , _Timestamp):
307- other = self . __class__ (other)
304+ other = type ( self ) (other)
308305 else :
309- self = other. __class__ (self )
306+ self = type ( other) (self )
310307
311308 # validate tz's
312309 if not tz_compare(self .tzinfo, other.tzinfo):
0 commit comments