diff options
| author | Nick Coghlan <ncoghlan@gmail.com> | 2006-05-03 13:02:47 (GMT) | 
|---|---|---|
| committer | Nick Coghlan <ncoghlan@gmail.com> | 2006-05-03 13:02:47 (GMT) | 
| commit | afd5e63e243b600e5344a34760d9e6565dafe1a9 (patch) | |
| tree | 6fdd6c7dd056fd5d4ce1e67e7d0b430b374dd270 /Lib/contextlib.py | |
| parent | 1b06a1d4e30729434630e9fa37b041926a5766f3 (diff) | |
| download | cpython-afd5e63e243b600e5344a34760d9e6565dafe1a9.zip cpython-afd5e63e243b600e5344a34760d9e6565dafe1a9.tar.gz cpython-afd5e63e243b600e5344a34760d9e6565dafe1a9.tar.bz2  | |
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()
Diffstat (limited to 'Lib/contextlib.py')
| -rw-r--r-- | Lib/contextlib.py | 16 | 
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/contextlib.py b/Lib/contextlib.py index 9d2c6a3..a807c42 100644 --- a/Lib/contextlib.py +++ b/Lib/contextlib.py @@ -2,10 +2,10 @@  import sys -__all__ = ["contextfactory", "nested", "closing"] +__all__ = ["contextmanager", "nested", "closing"] -class GeneratorContext(object): -    """Helper for @contextfactory decorator.""" +class GeneratorContextManager(object): +    """Helper for @contextmanager decorator."""      def __init__(self, gen):          self.gen = gen @@ -45,12 +45,12 @@ class GeneratorContext(object):                      raise -def contextfactory(func): -    """@contextfactory decorator. +def contextmanager(func): +    """@contextmanager decorator.      Typical usage: -        @contextfactory +        @contextmanager          def some_generator(<arguments>):              <setup>              try: @@ -74,7 +74,7 @@ def contextfactory(func):      """      def helper(*args, **kwds): -        return GeneratorContext(func(*args, **kwds)) +        return GeneratorContextManager(func(*args, **kwds))      try:          helper.__name__ = func.__name__          helper.__doc__ = func.__doc__ @@ -84,7 +84,7 @@ def contextfactory(func):      return helper -@contextfactory +@contextmanager  def nested(*managers):      """Support multiple context managers in a single with-statement.  | 
