File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -805,9 +805,16 @@ def _cmp(self, other):
805805 if self > other. This routine is for internal use only."""
806806
807807 if self ._is_special or other ._is_special :
808- return cmp (self ._isinfinity (), other ._isinfinity ())
808+ self_inf = self ._isinfinity ()
809+ other_inf = other ._isinfinity ()
810+ if self_inf == other_inf :
811+ return 0
812+ elif self_inf < other_inf :
813+ return - 1
814+ else :
815+ return 1
809816
810- # check for zeros; note that cmp(0, -0) should return 0
817+ # check for zeros; Decimal('0') == Decimal('-0')
811818 if not self :
812819 if not other :
813820 return 0
@@ -827,7 +834,12 @@ def _cmp(self, other):
827834 if self_adjusted == other_adjusted :
828835 self_padded = self ._int + '0' * (self ._exp - other ._exp )
829836 other_padded = other ._int + '0' * (other ._exp - self ._exp )
830- return cmp (self_padded , other_padded ) * (- 1 )** self ._sign
837+ if self_padded == other_padded :
838+ return 0
839+ elif self_padded < other_padded :
840+ return - (- 1 )** self ._sign
841+ else :
842+ return (- 1 )** self ._sign
831843 elif self_adjusted > other_adjusted :
832844 return (- 1 )** self ._sign
833845 else : # self_adjusted < other_adjusted
You can’t perform that action at this time.
0 commit comments