#Issue 8540: Make Context._clamp attribute public in decimal module.
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 2159088..50b660b 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -27,11 +27,13 @@
 import math
 import os, sys
 import operator
+import warnings
 import pickle, copy
 import unittest
 from decimal import *
 import numbers
 from test.support import run_unittest, run_doctest, is_resource_enabled
+from test.support import check_warnings
 import random
 try:
     import threading
@@ -412,7 +414,7 @@
     def change_max_exponent(self, exp):
         self.context.Emax = exp
     def change_clamp(self, clamp):
-        self.context._clamp = clamp
+        self.context.clamp = clamp
 
 
 
@@ -1815,6 +1817,26 @@
         self.assertNotEqual(id(c.flags), id(d.flags))
         self.assertNotEqual(id(c.traps), id(d.traps))
 
+    def test__clamp(self):
+        # In Python 3.2, the private attribute `_clamp` was made
+        # public (issue 8540), with the old `_clamp` becoming a
+        # property wrapping `clamp`.  For the duration of Python 3.2
+        # only, the attribute should be gettable/settable via both
+        # `clamp` and `_clamp`; in Python 3.3, `_clamp` should be
+        # removed.
+        c = Context(clamp = 0)
+        self.assertEqual(c.clamp, 0)
+
+        with check_warnings(("", DeprecationWarning)):
+            c._clamp = 1
+        self.assertEqual(c.clamp, 1)
+        with check_warnings(("", DeprecationWarning)):
+            self.assertEqual(c._clamp, 1)
+        c.clamp = 0
+        self.assertEqual(c.clamp, 0)
+        with check_warnings(("", DeprecationWarning)):
+            self.assertEqual(c._clamp, 0)
+
     def test_abs(self):
         c = Context()
         d = c.abs(Decimal(-1))