summaryrefslogtreecommitdiffstats
path: root/Lib/wave.py
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-07-31 17:46:08 (GMT)
committerR David Murray <rdmurray@bitdance.com>2013-07-31 17:46:08 (GMT)
commitc91d5eea106d191e931f953bdbdb1db25e051767 (patch)
tree4ddd0a8c329fc2fb9cc8a78900704829b889a303 /Lib/wave.py
parent0ce642ebca5f4d0e1b6875b845ad0eb8cb76bbb4 (diff)
downloadcpython-c91d5eea106d191e931f953bdbdb1db25e051767.zip
cpython-c91d5eea106d191e931f953bdbdb1db25e051767.tar.gz
cpython-c91d5eea106d191e931f953bdbdb1db25e051767.tar.bz2
#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.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/wave.py b/Lib/wave.py
index ea410c1..695a4be 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.
#