[Python-checkins] r72435 - in python/branches/py3k: Lib/aifc.py Lib/test/test_aifc.py Misc/NEWS

r.david.murray python-checkins at python.org
Thu May 7 20:24:38 CEST 2009


Author: r.david.murray
Date: Thu May  7 20:24:38 2009
New Revision: 72435

Log:
Merged revisions 72425-72426 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72425 | r.david.murray | 2009-05-07 12:27:02 -0400 (Thu, 07 May 2009) | 3 lines
  
  Issue5955: aifc's close method did not close the file it wrapped,
  now it does.  This also means getfp method now returns the real fp.
........
  r72426 | r.david.murray | 2009-05-07 12:29:19 -0400 (Thu, 07 May 2009) | 3 lines
  
  News item for Issue5955.
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Lib/aifc.py
   python/branches/py3k/Lib/test/test_aifc.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/aifc.py
==============================================================================
--- python/branches/py3k/Lib/aifc.py	(original)
+++ python/branches/py3k/Lib/aifc.py	Thu May  7 20:24:38 2009
@@ -281,10 +281,11 @@
         self._convert = None
         self._markers = []
         self._soundpos = 0
-        self._file = Chunk(file)
-        if self._file.getname() != b'FORM':
+        self._file = file
+        chunk = Chunk(file)
+        if chunk.getname() != b'FORM':
             raise Error('file does not start with FORM id')
-        formdata = self._file.read(4)
+        formdata = chunk.read(4)
         if formdata == b'AIFF':
             self._aifc = 0
         elif formdata == b'AIFC':

Modified: python/branches/py3k/Lib/test/test_aifc.py
==============================================================================
--- python/branches/py3k/Lib/test/test_aifc.py	(original)
+++ python/branches/py3k/Lib/test/test_aifc.py	Thu May  7 20:24:38 2009
@@ -94,6 +94,21 @@
         # XXX: this test fails, not sure if it should succeed or not
         # self.assertEqual(f.readframes(5), fout.readframes(5))
 
+    def test_close(self):
+        class Wrapfile(object):
+            def __init__(self, file):
+                self.file = open(file, 'rb')
+                self.closed = False
+            def close(self):
+                self.file.close()
+                self.closed = True
+            def __getattr__(self, attr): return getattr(self.file, attr)
+        testfile = Wrapfile(self.sndfilepath)
+        f = self.f = aifc.open(testfile)
+        self.assertEqual(testfile.closed, False)
+        f.close()
+        self.assertEqual(testfile.closed, True)
+
 
 def test_main():
     run_unittest(AIFCTest)

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Thu May  7 20:24:38 2009
@@ -15,6 +15,9 @@
 Library
 -------
 
+- Issue 5955: aifc's close method did not close the file it wrapped,
+  now it does.  This also means getfp method now returns the real fp.
+
 
 What's New in Python 3.1 beta 1?
 ================================


More information about the Python-checkins mailing list