diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-07-31 13:46:08 -0400 |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-07-31 13:46:08 -0400 |
commit | 1008af0646a99a5aa413903baebedd6e43cae06b (patch) | |
tree | e32be2788edb40ccbbe9f7f6e4faaf7eb2d54931 /Lib/wave.py | |
parent | e16d0f8eb8bf88aa4bfc09cea794c751bfe81e2c (diff) | |
download | cpython-1008af0646a99a5aa413903baebedd6e43cae06b.tar.gz |
#17616: wave.open now supports the 'with' statement.
Feature and tests by ClClaudiu.Popa, I added the doc changes.
Diffstat (limited to 'Lib/wave.py')
-rw-r--r-- | Lib/wave.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/wave.py b/Lib/wave.py index ea410c12d7..695a4be838 100644 --- a/Lib/wave.py +++ b/Lib/wave.py @@ -167,6 +167,13 @@ class Wave_read: def __del__(self): self.close() + + def __enter__(self): + return self + + def __exit__(self, *args): + self.close() + # # User visible methods. # @@ -323,6 +330,12 @@ class Wave_write: def __del__(self): self.close() + def __enter__(self): + return self + + def __exit__(self, *args): + self.close() + # # User visible methods. # |