diff options
author | Raymond Hettinger <python@rcn.com> | 2004-07-14 16:35:30 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-07-14 16:35:30 +0000 |
commit | 3cf0bd251ad1834507ff945f11621b4e6098e583 (patch) | |
tree | 57ed8a3173a59642ba6bcb6b1cdf5fa880f0fbb0 /Lib | |
parent | 4d5e9f50cef9727ee77113ef4634c3e340319b49 (diff) | |
download | cpython-3cf0bd251ad1834507ff945f11621b4e6098e583.tar.gz |
* Hide a loop induction variable that was inadvertantly being picked up
by the locals() call in the context constructor.
* Remove unnecessary properties for int, exp, and sign which duplicated
information returned by as_tuple().
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/decimal.py | 13 | ||||
-rw-r--r-- | Lib/test/test_decimal.py | 28 |
2 files changed, 2 insertions, 39 deletions
diff --git a/Lib/decimal.py b/Lib/decimal.py index 88fa031c29..9cc9c0fe42 100644 --- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -2054,17 +2054,6 @@ class Decimal(object): except TypeError: return 0 - #properties to immutability-near feature - def _get_sign(self): - return self._sign - def _get_int(self): - return self._int - def _get_exp(self): - return self._exp - sign = property(_get_sign) - int = property(_get_int) - exp = property(_get_exp) - # support for pickling, copy, and deepcopy def __reduce__(self): return (self.__class__, (str(self),)) @@ -2120,8 +2109,10 @@ class Context(object): _ignored_flags=[]): if not isinstance(flags, dict): flags = dict([(s,s in flags) for s in _signals]) + del s if traps is not None and not isinstance(traps, dict): traps = dict([(s,s in traps) for s in _signals]) + del s for name, val in locals().items(): if val is None: setattr(self, name, copy.copy(getattr(DefaultContext, name))) diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 2415a78c6e..0a23808f5f 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -954,34 +954,6 @@ class DecimalUsabilityTest(unittest.TestCase): d = Decimal("Infinity") self.assertEqual(d.as_tuple(), (0, (0,), 'F') ) - def test_immutability_onpurpose(self): - #Try to change internal objects and see if immutable. - - d = Decimal(42) - - #you can get the attributes... - d.exp - d.int - d.sign - - #...but not change them! - try: - d.exp = 20 - d.int = 3 - d.sign = 1 - except AttributeError: - pass - else: - self.fail('Did not raised an error!') - - #some new attribute - try: - d.newone = None - except AttributeError: - pass - else: - self.fail('Did not raised an error!') - def test_immutability_operations(self): # Do operations and check that it didn't change change internal objects. |