mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
Issue #7461: objects returned by os.popen() should support the context manager protocol
This commit is contained in:
parent
9b14f6044c
commit
ac62535164
2 changed files with 12 additions and 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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue