summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/aifc.py7
-rw-r--r--Lib/test/test_aifc.py15
-rw-r--r--Misc/NEWS3
3 files changed, 22 insertions, 3 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py
index c03446f..015d398 100644
--- a/Lib/aifc.py
+++ b/Lib/aifc.py
@@ -281,10 +281,11 @@ class Aifc_read:
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':
diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py
index 1e84bd6..0248615 100644
--- a/Lib/test/test_aifc.py
+++ b/Lib/test/test_aifc.py
@@ -94,6 +94,21 @@ class AIFCTest(unittest.TestCase):
# 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)
diff --git a/Misc/NEWS b/Misc/NEWS
index 2464c04..1c5734c 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -15,6 +15,9 @@ Core and Builtins
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?
================================