cpython: 221638ba5d2a (original) (raw)
Mercurial > cpython
changeset 73091:221638ba5d2a
Issue #13248, issue #8540: Remove deprecated Context._clamp attribute from Decimal module. [#13248]
Mark Dickinson mdickinson@enthought.com | |
---|---|
date | Mon, 24 Oct 2011 10:31:52 +0100 |
parents | 4eb65a7f2fbe |
children | b82e68cf3b0d |
files | Lib/decimal.py Lib/test/test_decimal.py Misc/NEWS |
diffstat | 3 files changed, 5 insertions(+), 34 deletions(-)[+] [-] Lib/decimal.py 22 Lib/test/test_decimal.py 15 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Lib/decimal.py +++ b/Lib/decimal.py @@ -3903,28 +3903,6 @@ class Context(object): return nc copy = copy
_clamp is provided for backwards compatibility with third-party
code. May be removed in Python >= 3.3.
- def _get_clamp(self):
"_clamp mirrors the clamp attribute. Its use is deprecated."[](#l1.10)
import warnings[](#l1.11)
warnings.warn('Use of the _clamp attribute is deprecated. '[](#l1.12)
'Please use clamp instead.',[](#l1.13)
DeprecationWarning)[](#l1.14)
return self.clamp[](#l1.15)
- def _set_clamp(self, clamp):
"_clamp mirrors the clamp attribute. Its use is deprecated."[](#l1.18)
import warnings[](#l1.19)
warnings.warn('Use of the _clamp attribute is deprecated. '[](#l1.20)
'Please use clamp instead.',[](#l1.21)
DeprecationWarning)[](#l1.22)
self.clamp = clamp[](#l1.23)
don't bother with _del_clamp; no sane 3rd party code should
be deleting the _clamp attribute
- _clamp = property(_get_clamp, _set_clamp)
- def _raise_error(self, condition, explanation = None, *args): """Handles an error
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -1834,18 +1834,9 @@ class ContextAPItests(unittest.TestCase)
# only, the attribute should be gettable/settable via both
# clamp
and _clamp
; in Python 3.3, _clamp
should be
# removed.
c = Context(clamp = 0)[](#l2.7)
self.assertEqual(c.clamp, 0)[](#l2.8)
with check_warnings(("", DeprecationWarning)):[](#l2.10)
c._clamp = 1[](#l2.11)
self.assertEqual(c.clamp, 1)[](#l2.12)
with check_warnings(("", DeprecationWarning)):[](#l2.13)
self.assertEqual(c._clamp, 1)[](#l2.14)
c.clamp = 0[](#l2.15)
self.assertEqual(c.clamp, 0)[](#l2.16)
with check_warnings(("", DeprecationWarning)):[](#l2.17)
self.assertEqual(c._clamp, 0)[](#l2.18)
c = Context()[](#l2.19)
with self.assertRaises(AttributeError):[](#l2.20)
clamp_value = c._clamp[](#l2.21)
def test_abs(self): c = Context()
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -338,6 +338,8 @@ Core and Builtins Library ------- +- Issue #8540: Remove deprecated Context._clamp attribute in Decimal module. +