Get rid of __context__, per the latest changes to PEP 343 and python-dev
discussion.
There are two places of documentation that still mention __context__:
Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without
spending a whole lot of time thinking about it; and whatsnew, which Andrew
usually likes to change himself.
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index 53f23b2..8d3dd1a 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -51,7 +51,7 @@
@contextfactory
def whee():
yield
- ctx = whee().__context__()
+ ctx = whee()
ctx.__enter__()
# Calling __exit__ should not result in an exception
self.failIf(ctx.__exit__(TypeError, TypeError("foo"), None))
@@ -63,7 +63,7 @@
yield
except:
yield
- ctx = whoo().__context__()
+ ctx = whoo()
ctx.__enter__()
self.assertRaises(
RuntimeError, ctx.__exit__, TypeError, TypeError("foo"), None
@@ -152,8 +152,6 @@
def a():
yield 1
class b(object):
- def __context__(self):
- return self
def __enter__(self):
return 2
def __exit__(self, *exc_info):
@@ -341,12 +339,12 @@
orig_context = ctx.copy()
try:
ctx.prec = save_prec = decimal.ExtendedContext.prec + 5
- with decimal.ExtendedContext:
+ with decimal.ExtendedContext.context_manager():
self.assertEqual(decimal.getcontext().prec,
decimal.ExtendedContext.prec)
self.assertEqual(decimal.getcontext().prec, save_prec)
try:
- with decimal.ExtendedContext:
+ with decimal.ExtendedContext.context_manager():
self.assertEqual(decimal.getcontext().prec,
decimal.ExtendedContext.prec)
1/0