summaryrefslogtreecommitdiff
path: root/Lib/os.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-12-09 00:03:16 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2009-12-09 00:03:16 +0000
commitfcab97bb677a75c5f90aa05482f607b470b52861 (patch)
tree7c0420166ebad6fbb28ad5f5c8556acbf7121c22 /Lib/os.py
parent92d337808221775fce5c5fb682ea788e276063a8 (diff)
downloadcpython-fcab97bb677a75c5f90aa05482f607b470b52861.tar.gz
Merged revisions 76723 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r76723 | antoine.pitrou | 2009-12-09 01:01:27 +0100 (mer., 09 déc. 2009) | 3 lines Issue #7461: objects returned by os.popen() should support the context manager protocol ........
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/os.py b/Lib/os.py
index a59c5df1f6..7c342feb43 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -650,6 +650,10 @@ class _wrap_close:
return returncode
else:
return returncode << 8 # Shift left to match old behavior
+ def __enter__(self):
+ return self
+ def __exit__(self, *args):
+ self.close()
def __getattr__(self, name):
return getattr(self._stream, name)
def __iter__(self):