Kaydet (Commit) 8fd522fb authored tarafından R. David Murray's avatar R. David Murray

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.
üst 02588111
...@@ -282,10 +282,11 @@ class Aifc_read: ...@@ -282,10 +282,11 @@ class Aifc_read:
self._convert = None self._convert = None
self._markers = [] self._markers = []
self._soundpos = 0 self._soundpos = 0
self._file = Chunk(file) self._file = file
if self._file.getname() != 'FORM': chunk = Chunk(file)
if chunk.getname() != 'FORM':
raise Error, 'file does not start with FORM id' raise Error, 'file does not start with FORM id'
formdata = self._file.read(4) formdata = chunk.read(4)
if formdata == 'AIFF': if formdata == 'AIFF':
self._aifc = 0 self._aifc = 0
elif formdata == 'AIFC': elif formdata == 'AIFC':
......
...@@ -91,6 +91,21 @@ class AIFCTest(unittest.TestCase): ...@@ -91,6 +91,21 @@ class AIFCTest(unittest.TestCase):
# XXX: this test fails, not sure if it should succeed or not # XXX: this test fails, not sure if it should succeed or not
# self.assertEqual(f.readframes(5), fout.readframes(5)) # self.assertEqual(f.readframes(5), fout.readframes(5))
def test_close(self):
class Wrapfile(object):
def __init__(self, file):
self.file = open(file)
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(): def test_main():
run_unittest(AIFCTest) run_unittest(AIFCTest)
......
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