summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-08-25 19:12:56 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2013-08-25 19:12:56 +0300
commit9071eae9d0c966a91c76bbb7eb543a2a633e0bb3 (patch)
treeb94d89ff50d937d419f185bcf7990cec63adbcf2
parente0184dda7345800df932d01972e42f8ffb81843f (diff)
downloadcpython-9071eae9d0c966a91c76bbb7eb543a2a633e0bb3.tar.gz
Issue #18817: Fix a resource warning in Lib/aifc.py demo.
-rw-r--r--Lib/aifc.py42
-rw-r--r--Misc/NEWS2
2 files changed, 25 insertions, 19 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py
index 29545a5fb8..3270047b11 100644
--- a/Lib/aifc.py
+++ b/Lib/aifc.py
@@ -873,23 +873,27 @@ if __name__ == '__main__':
sys.argv.append('/usr/demos/data/audio/bach.aiff')
fn = sys.argv[1]
f = open(fn, 'r')
- print("Reading", fn)
- print("nchannels =", f.getnchannels())
- print("nframes =", f.getnframes())
- print("sampwidth =", f.getsampwidth())
- print("framerate =", f.getframerate())
- print("comptype =", f.getcomptype())
- print("compname =", f.getcompname())
- if sys.argv[2:]:
- gn = sys.argv[2]
- print("Writing", gn)
- g = open(gn, 'w')
- g.setparams(f.getparams())
- while 1:
- data = f.readframes(1024)
- if not data:
- break
- g.writeframes(data)
- g.close()
+ try:
+ print("Reading", fn)
+ print("nchannels =", f.getnchannels())
+ print("nframes =", f.getnframes())
+ print("sampwidth =", f.getsampwidth())
+ print("framerate =", f.getframerate())
+ print("comptype =", f.getcomptype())
+ print("compname =", f.getcompname())
+ if sys.argv[2:]:
+ gn = sys.argv[2]
+ print("Writing", gn)
+ g = open(gn, 'w')
+ try:
+ g.setparams(f.getparams())
+ while 1:
+ data = f.readframes(1024)
+ if not data:
+ break
+ g.writeframes(data)
+ finally:
+ g.close()
+ print("Done.")
+ finally:
f.close()
- print("Done.")
diff --git a/Misc/NEWS b/Misc/NEWS
index 848332c1e0..6de48123e7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -378,6 +378,8 @@ Documentation
Tools/Demos
-----------
+- Issue #18817: Fix a resource warning in Lib/aifc.py demo.
+
- Issue #18439: Make patchcheck work on Windows for ACKS, NEWS.
- Issue #18448: Fix a typo in Tools/demo/eiffel.py.