diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-12-09 00:01:27 +0000 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-12-09 00:01:27 +0000 |
commit | 542d221b5f39c55a1785bcbda415ab31bd6318a7 (patch) | |
tree | 9bebf6680b66dfa3acf0a5515c274b5aca0d4342 /Lib/os.py | |
parent | 167361223610b3f74ffd02d3868912cbaea6840f (diff) | |
download | cpython-542d221b5f39c55a1785bcbda415ab31bd6318a7.tar.gz |
Issue #7461: objects returned by os.popen() should support the context manager protocol
Diffstat (limited to 'Lib/os.py')
-rw-r--r-- | Lib/os.py | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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): |