diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2009-12-09 00:01:27 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2009-12-09 00:01:27 (GMT) |
commit | ac625351643d5732bcaa77844ef1506bf5c978ab (patch) | |
tree | 620f07c70671ea90bd42d61ae51d0fcf19a93f34 /Lib/os.py | |
parent | 9b14f6044ce261ed2c9154d1c8466ff50e697c2e (diff) | |
download | cpython-ac625351643d5732bcaa77844ef1506bf5c978ab.zip cpython-ac625351643d5732bcaa77844ef1506bf5c978ab.tar.gz cpython-ac625351643d5732bcaa77844ef1506bf5c978ab.tar.bz2 |
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): |