]> granicus.if.org Git - python/commitdiff
Issue #18817: Fix a resource warning in Lib/aifc.py demo. Patch by
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 25 Aug 2013 16:16:01 +0000 (19:16 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 25 Aug 2013 16:16:01 +0000 (19:16 +0300)
Vajrasky Kok.

1  2 
Lib/aifc.py
Misc/NEWS

diff --cc Lib/aifc.py
index c02c485bb096c979ea02a594df973d8deb9bf5c9,3270047b11359a2efb9bdee16da178fba945dae9..b08775485cd177707650b4670a0f133196a6d325
@@@ -889,24 -872,28 +889,22 @@@ if __name__ == '__main__'
      if not sys.argv[1:]:
          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()
-         f.close()
-         print("Done.")
 -    try:
++    with open(fn, 'r') as f:
+         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:
++            with open(gn, 'w') as g:
+                 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()
diff --cc Misc/NEWS
index 7e5b1d629dc54a2c9aac32e20ce5639bb403ddc0,6de48123e7d1fb307cf9b7580bdacb5463484665..b923109b8cea47d724f9ecfba45d72747fbaa2e4
+++ b/Misc/NEWS
@@@ -957,24 -652,24 +957,27 @@@ Buil
  - Issue #17547: In configure, explicitly pass -Wformat for the benefit for GCC
    4.8.
  
 -- Issue #17962: Build with OpenSSL 1.0.1e on Windows.
 -
 +- Issue #15172: Document NASM 2.10+ as requirement for building OpenSSL 1.0.1
 +  on Windows.
  
 -What's New in Python 3.3.1?
 -===========================
 +Tools/Demos
 +-----------
  
 -*Release date: 07-Apr-2013*
++- Issue #18817: Fix a resource warning in Lib/aifc.py demo.  Patch by
++  Vajrasky Kok.
 -Build
 ------
 +- Issue #18439: Make patchcheck work on Windows for ACKS, NEWS.
  
 -- Issue #17550: Fix the --enable-profiling configure switch.
 +- Issue #18448: Fix a typo in Tools/demo/eiffel.py.
  
 -IDLE
 --------
 +- Issue #18457: Fixed saving of formulas and complex numbers in
 +  Tools/demo/ss1.py.
  
 -- Issue #17625: In IDLE, close the replace dialog after it is used.
 +- Issue #18449: Make Tools/demo/ss1.py work again on Python 3.  Patch by
 +  FĂ©vry Thibault.
  
 +- Issue #12990: The "Python Launcher" on OSX could not launch python scripts
 +  that have paths that include wide characters.
  
  What's New in Python 3.3.1 release candidate 1?
  ===============================================