summaryrefslogtreecommitdiffstats
path: root/Lib/contextlib.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-07-01 01:32:12 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-07-01 01:32:12 (GMT)
commit9c4d0edd645764844b53fc634fb11a9bf4683e87 (patch)
tree8079bb5cf382e3035783d8a6999d4754555d8a3d /Lib/contextlib.py
parent6e5b0a1140536f55ffb59cac255b12f9db1597a6 (diff)
downloadcpython-9c4d0edd645764844b53fc634fb11a9bf4683e87.zip
cpython-9c4d0edd645764844b53fc634fb11a9bf4683e87.tar.gz
cpython-9c4d0edd645764844b53fc634fb11a9bf4683e87.tar.bz2
Removed contextlib.nested()
Diffstat (limited to 'Lib/contextlib.py')
-rw-r--r--Lib/contextlib.py45
1 files changed, 0 insertions, 45 deletions
diff --git a/Lib/contextlib.py b/Lib/contextlib.py
index bffa0c4..d14c07b 100644
--- a/Lib/contextlib.py
+++ b/Lib/contextlib.py
@@ -85,51 +85,6 @@ def contextmanager(func):
return helper
-@contextmanager
-def nested(*managers):
- """Combine multiple context managers into a single nested context manager.
-
- This function has been deprecated in favour of the multiple manager form
- of the with statement.
-
- The one advantage of this function over the multiple manager form of the
- with statement is that argument unpacking allows it to be
- used with a variable number of context managers as follows:
-
- with nested(*managers):
- do_something()
-
- """
- warn("With-statements now directly support multiple context managers",
- DeprecationWarning, 3)
- exits = []
- vars = []
- exc = (None, None, None)
- try:
- for mgr in managers:
- exit = mgr.__exit__
- enter = mgr.__enter__
- vars.append(enter())
- exits.append(exit)
- yield vars
- except:
- exc = sys.exc_info()
- finally:
- while exits:
- exit = exits.pop()
- try:
- if exit(*exc):
- exc = (None, None, None)
- except:
- exc = sys.exc_info()
- if exc != (None, None, None):
- # Don't rely on sys.exc_info() still containing
- # the right information. Another exception may
- # have been raised and caught by an exit method
- # exc[1] already has the __traceback__ attribute populated
- raise exc[1]
-
-
class closing(object):
"""Context to automatically close something at the end of a block.