Issue #18817: Fix a resource warning in Lib/aifc.py demo. Patch by

Vajrasky Kok.
This commit is contained in:
Serhiy Storchaka 2013-08-25 19:16:01 +03:00
commit 58b3ebfab9
2 changed files with 22 additions and 21 deletions

View File

@ -889,7 +889,7 @@ if __name__ == '__main__':
if not sys.argv[1:]: if not sys.argv[1:]:
sys.argv.append('/usr/demos/data/audio/bach.aiff') sys.argv.append('/usr/demos/data/audio/bach.aiff')
fn = sys.argv[1] fn = sys.argv[1]
f = open(fn, 'r') with open(fn, 'r') as f:
print("Reading", fn) print("Reading", fn)
print("nchannels =", f.getnchannels()) print("nchannels =", f.getnchannels())
print("nframes =", f.getnframes()) print("nframes =", f.getnframes())
@ -900,13 +900,11 @@ if __name__ == '__main__':
if sys.argv[2:]: if sys.argv[2:]:
gn = sys.argv[2] gn = sys.argv[2]
print("Writing", gn) print("Writing", gn)
g = open(gn, 'w') with open(gn, 'w') as g:
g.setparams(f.getparams()) g.setparams(f.getparams())
while 1: while 1:
data = f.readframes(1024) data = f.readframes(1024)
if not data: if not data:
break break
g.writeframes(data) g.writeframes(data)
g.close()
f.close()
print("Done.") print("Done.")

View File

@ -963,6 +963,9 @@ Build
Tools/Demos Tools/Demos
----------- -----------
- Issue #18817: Fix a resource warning in Lib/aifc.py demo. Patch by
Vajrasky Kok.
- Issue #18439: Make patchcheck work on Windows for ACKS, NEWS. - Issue #18439: Make patchcheck work on Windows for ACKS, NEWS.
- Issue #18448: Fix a typo in Tools/demo/eiffel.py. - Issue #18448: Fix a typo in Tools/demo/eiffel.py.