mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
#17616: wave.open now supports the 'with' statement.
Feature and tests by ClClaudiu.Popa, I added the doc changes.
This commit is contained in:
parent
0ce642ebca
commit
c91d5eea10
6 changed files with 45 additions and 12 deletions
13
Lib/wave.py
13
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.
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue