LEFT | RIGHT |
1 # Copyright (c) 2004 Python Software Foundation. | 1 # Copyright (c) 2004 Python Software Foundation. |
2 # All rights reserved. | 2 # All rights reserved. |
3 | 3 |
4 # Written by Eric Price <eprice at tjhsst.edu> | 4 # Written by Eric Price <eprice at tjhsst.edu> |
5 # and Facundo Batista <facundo at taniquetil.com.ar> | 5 # and Facundo Batista <facundo at taniquetil.com.ar> |
6 # and Raymond Hettinger <python at rcn.com> | 6 # and Raymond Hettinger <python at rcn.com> |
7 # and Aahz <aahz at pobox.com> | 7 # and Aahz <aahz at pobox.com> |
8 # and Tim Peters | 8 # and Tim Peters |
9 | 9 |
10 # This module is currently Py2.3 compatible and should be kept that way | 10 # This module is currently Py2.3 compatible and should be kept that way |
(...skipping 3765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3776 self._ignored_flags = (self._ignored_flags + list(flags)) | 3776 self._ignored_flags = (self._ignored_flags + list(flags)) |
3777 return list(flags) | 3777 return list(flags) |
3778 | 3778 |
3779 def _regard_flags(self, *flags): | 3779 def _regard_flags(self, *flags): |
3780 """Stop ignoring the flags, if they are raised""" | 3780 """Stop ignoring the flags, if they are raised""" |
3781 if flags and isinstance(flags[0], (tuple,list)): | 3781 if flags and isinstance(flags[0], (tuple,list)): |
3782 flags = flags[0] | 3782 flags = flags[0] |
3783 for flag in flags: | 3783 for flag in flags: |
3784 self._ignored_flags.remove(flag) | 3784 self._ignored_flags.remove(flag) |
3785 | 3785 |
3786 def __hash__(self): | 3786 # We inherit object.__hash__, so we must deny this explicitly |
3787 """A Context cannot be hashed.""" | 3787 __hash__ = None |
3788 # We inherit object.__hash__, so we must deny this explicitly | |
3789 raise TypeError("Cannot hash a Context.") | |
3790 | 3788 |
3791 def Etiny(self): | 3789 def Etiny(self): |
3792 """Returns Etiny (= Emin - prec + 1)""" | 3790 """Returns Etiny (= Emin - prec + 1)""" |
3793 return int(self.Emin - self.prec + 1) | 3791 return int(self.Emin - self.prec + 1) |
3794 | 3792 |
3795 def Etop(self): | 3793 def Etop(self): |
3796 """Returns maximum exponent (= Emax - prec + 1)""" | 3794 """Returns maximum exponent (= Emax - prec + 1)""" |
3797 return int(self.Emax - self.prec + 1) | 3795 return int(self.Emax - self.prec + 1) |
3798 | 3796 |
3799 def _set_rounding(self, type): | 3797 def _set_rounding(self, type): |
(...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5582 Dec_n1 = Decimal(-1) | 5580 Dec_n1 = Decimal(-1) |
5583 | 5581 |
5584 # Infsign[sign] is infinity w/ that sign | 5582 # Infsign[sign] is infinity w/ that sign |
5585 Infsign = (Inf, negInf) | 5583 Infsign = (Inf, negInf) |
5586 | 5584 |
5587 | 5585 |
5588 | 5586 |
5589 if __name__ == '__main__': | 5587 if __name__ == '__main__': |
5590 import doctest, sys | 5588 import doctest, sys |
5591 doctest.testmod(sys.modules[__name__]) | 5589 doctest.testmod(sys.modules[__name__]) |
LEFT | RIGHT |