Finish bringing SVN into line with latest version of PEP 343 by getting rid of all remaining references to context objects that I could find. Without a __context__() method context objects no longer exist. Also get test_with working again, and adopt a suggestion from Neal for decimal.Context.get_manager()
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index 765bfec..5750508 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -10,25 +10,26 @@
import sys
import unittest
from collections import deque
-from contextlib import GeneratorContext, contextfactory
+from contextlib import GeneratorContextManager, contextmanager
from test.test_support import run_unittest
-class MockContextManager(GeneratorContext):
+class MockContextManager(GeneratorContextManager):
def __init__(self, gen):
- GeneratorContext.__init__(self, gen)
+ GeneratorContextManager.__init__(self, gen)
self.enter_called = False
self.exit_called = False
self.exit_args = None
def __enter__(self):
self.enter_called = True
- return GeneratorContext.__enter__(self)
+ return GeneratorContextManager.__enter__(self)
def __exit__(self, type, value, traceback):
self.exit_called = True
self.exit_args = (type, value, traceback)
- return GeneratorContext.__exit__(self, type, value, traceback)
+ return GeneratorContextManager.__exit__(self, type,
+ value, traceback)
def mock_contextmanager(func):
@@ -439,7 +440,7 @@
self.assertAfterWithGeneratorInvariantsNoError(self.bar)
def testRaisedStopIteration1(self):
- @contextfactory
+ @contextmanager
def cm():
yield
@@ -463,7 +464,7 @@
self.assertRaises(StopIteration, shouldThrow)
def testRaisedGeneratorExit1(self):
- @contextfactory
+ @contextmanager
def cm():
yield