Commit 6f32f33b authored by Serhiy Storchaka's avatar Serhiy Storchaka

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

parent b92e104d
...@@ -873,23 +873,27 @@ if __name__ == '__main__': ...@@ -873,23 +873,27 @@ if __name__ == '__main__':
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') f = open(fn, 'r')
print("Reading", fn) try:
print("nchannels =", f.getnchannels()) print("Reading", fn)
print("nframes =", f.getnframes()) print("nchannels =", f.getnchannels())
print("sampwidth =", f.getsampwidth()) print("nframes =", f.getnframes())
print("framerate =", f.getframerate()) print("sampwidth =", f.getsampwidth())
print("comptype =", f.getcomptype()) print("framerate =", f.getframerate())
print("compname =", f.getcompname()) print("comptype =", f.getcomptype())
if sys.argv[2:]: print("compname =", f.getcompname())
gn = sys.argv[2] if sys.argv[2:]:
print("Writing", gn) gn = sys.argv[2]
g = open(gn, 'w') print("Writing", gn)
g.setparams(f.getparams()) g = open(gn, 'w')
while 1: try:
data = f.readframes(1024) g.setparams(f.getparams())
if not data: while 1:
break data = f.readframes(1024)
g.writeframes(data) if not data:
g.close() break
g.writeframes(data)
finally:
g.close()
print("Done.")
finally:
f.close() f.close()
print("Done.")
...@@ -378,6 +378,8 @@ Documentation ...@@ -378,6 +378,8 @@ Documentation
Tools/Demos Tools/Demos
----------- -----------
- Issue #18817: Fix a resource warning in Lib/aifc.py demo.
- 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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment