aubioclass.py: make sndfile raise error if file not opened, do not delete it if ...
authorPaul Brossier <piem@piem.org>
Thu, 1 Nov 2007 14:14:29 +0000 (15:14 +0100)
committerPaul Brossier <piem@piem.org>
Thu, 1 Nov 2007 14:14:29 +0000 (15:14 +0100)
python/aubio/aubioclass.py

index 4269e29a011e5ccfa8aede3753b50b58353b6607..b6e5be38787364ff243599f084bd2113d6071941 100644 (file)
@@ -42,8 +42,9 @@ class sndfile:
             self.file = new_aubio_sndfile_wo(model.file,filename)
         else:
             self.file = new_aubio_sndfile_ro(filename)
+        if self.file == None: raise(ValueError, "failed opening file")
     def __del__(self):
-        del_aubio_sndfile(self.file)
+        if self.file != None: del_aubio_sndfile(self.file)
     def info(self):
         aubio_sndfile_info(self.file)
     def samplerate(self):