@@ -287,14 +287,14 @@ def initfp(self, file):
287287 self ._soundpos = 0
288288 self ._file = Chunk (file )
289289 if self ._file .getname () != 'FORM' :
290- raise Error , 'file does not start with FORM id'
290+ raise Error ( 'file does not start with FORM id' )
291291 formdata = self ._file .read (4 )
292292 if formdata == 'AIFF' :
293293 self ._aifc = 0
294294 elif formdata == 'AIFC' :
295295 self ._aifc = 1
296296 else :
297- raise Error , 'not an AIFF or AIFF-C file'
297+ raise Error ( 'not an AIFF or AIFF-C file' )
298298 self ._comm_chunk_read = 0
299299 while 1 :
300300 self ._ssnd_seek_needed = 1
@@ -317,10 +317,10 @@ def initfp(self, file):
317317 elif chunkname in _skiplist :
318318 pass
319319 else :
320- raise Error , 'unrecognized chunk type ' + chunk .chunkname
320+ raise Error ( 'unrecognized chunk type ' + chunk .chunkname )
321321 chunk .skip ()
322322 if not self ._comm_chunk_read or not self ._ssnd_chunk :
323- raise Error , 'COMM chunk and/or SSND chunk missing'
323+ raise Error ( 'COMM chunk and/or SSND chunk missing' )
324324 if self ._aifc and self ._decomp :
325325 import cl
326326 params = [cl .ORIGINAL_FORMAT , 0 ,
@@ -331,7 +331,7 @@ def initfp(self, file):
331331 elif self ._nchannels == 2 :
332332 params [1 ] = cl .STEREO_INTERLEAVED
333333 else :
334- raise Error , 'cannot compress more than 2 channels'
334+ raise Error ( 'cannot compress more than 2 channels' )
335335 self ._decomp .SetParams (params )
336336
337337 def __init__ (self , f ):
@@ -394,11 +394,11 @@ def getmark(self, id):
394394 for marker in self ._markers :
395395 if id == marker [0 ]:
396396 return marker
397- raise Error , 'marker %r does not exist' % (id ,)
397+ raise Error ( 'marker %r does not exist' % (id ,) )
398398
399399 def setpos (self , pos ):
400400 if pos < 0 or pos > self ._nframes :
401- raise Error , 'position not in range'
401+ raise Error ( 'position not in range' )
402402 self ._soundpos = pos
403403 self ._ssnd_seek_needed = 1
404404
@@ -488,15 +488,15 @@ def _read_comm_chunk(self, chunk):
488488 return
489489 except ImportError :
490490 pass
491- raise Error , 'cannot read compressed AIFF-C files'
491+ raise Error ( 'cannot read compressed AIFF-C files' )
492492 if self ._comptype == 'ULAW' :
493493 scheme = cl .G711_ULAW
494494 self ._framesize = self ._framesize / 2
495495 elif self ._comptype == 'ALAW' :
496496 scheme = cl .G711_ALAW
497497 self ._framesize = self ._framesize / 2
498498 else :
499- raise Error , 'unsupported compression type'
499+ raise Error ( 'unsupported compression type' )
500500 self ._decomp = cl .OpenDecompressor (scheme )
501501 self ._convert = self ._decomp_data
502502 else :
@@ -594,63 +594,63 @@ def __del__(self):
594594 #
595595 def aiff (self ):
596596 if self ._nframeswritten :
597- raise Error , 'cannot change parameters after starting to write'
597+ raise Error ( 'cannot change parameters after starting to write' )
598598 self ._aifc = 0
599599
600600 def aifc (self ):
601601 if self ._nframeswritten :
602- raise Error , 'cannot change parameters after starting to write'
602+ raise Error ( 'cannot change parameters after starting to write' )
603603 self ._aifc = 1
604604
605605 def setnchannels (self , nchannels ):
606606 if self ._nframeswritten :
607- raise Error , 'cannot change parameters after starting to write'
607+ raise Error ( 'cannot change parameters after starting to write' )
608608 if nchannels < 1 :
609- raise Error , 'bad # of channels'
609+ raise Error ( 'bad # of channels' )
610610 self ._nchannels = nchannels
611611
612612 def getnchannels (self ):
613613 if not self ._nchannels :
614- raise Error , 'number of channels not set'
614+ raise Error ( 'number of channels not set' )
615615 return self ._nchannels
616616
617617 def setsampwidth (self , sampwidth ):
618618 if self ._nframeswritten :
619- raise Error , 'cannot change parameters after starting to write'
619+ raise Error ( 'cannot change parameters after starting to write' )
620620 if sampwidth < 1 or sampwidth > 4 :
621- raise Error , 'bad sample width'
621+ raise Error ( 'bad sample width' )
622622 self ._sampwidth = sampwidth
623623
624624 def getsampwidth (self ):
625625 if not self ._sampwidth :
626- raise Error , 'sample width not set'
626+ raise Error ( 'sample width not set' )
627627 return self ._sampwidth
628628
629629 def setframerate (self , framerate ):
630630 if self ._nframeswritten :
631- raise Error , 'cannot change parameters after starting to write'
631+ raise Error ( 'cannot change parameters after starting to write' )
632632 if framerate <= 0 :
633- raise Error , 'bad frame rate'
633+ raise Error ( 'bad frame rate' )
634634 self ._framerate = framerate
635635
636636 def getframerate (self ):
637637 if not self ._framerate :
638- raise Error , 'frame rate not set'
638+ raise Error ( 'frame rate not set' )
639639 return self ._framerate
640640
641641 def setnframes (self , nframes ):
642642 if self ._nframeswritten :
643- raise Error , 'cannot change parameters after starting to write'
643+ raise Error ( 'cannot change parameters after starting to write' )
644644 self ._nframes = nframes
645645
646646 def getnframes (self ):
647647 return self ._nframeswritten
648648
649649 def setcomptype (self , comptype , compname ):
650650 if self ._nframeswritten :
651- raise Error , 'cannot change parameters after starting to write'
651+ raise Error ( 'cannot change parameters after starting to write' )
652652 if comptype not in ('NONE' , 'ULAW' , 'ALAW' , 'G722' ):
653- raise Error , 'unsupported compression type'
653+ raise Error ( 'unsupported compression type' )
654654 self ._comptype = comptype
655655 self ._compname = compname
656656
@@ -668,9 +668,9 @@ def getcompname(self):
668668 def setparams (self , params ):
669669 nchannels , sampwidth , framerate , nframes , comptype , compname = params
670670 if self ._nframeswritten :
671- raise Error , 'cannot change parameters after starting to write'
671+ raise Error ( 'cannot change parameters after starting to write' )
672672 if comptype not in ('NONE' , 'ULAW' , 'ALAW' , 'G722' ):
673- raise Error , 'unsupported compression type'
673+ raise Error ( 'unsupported compression type' )
674674 self .setnchannels (nchannels )
675675 self .setsampwidth (sampwidth )
676676 self .setframerate (framerate )
@@ -679,17 +679,17 @@ def setparams(self, params):
679679
680680 def getparams (self ):
681681 if not self ._nchannels or not self ._sampwidth or not self ._framerate :
682- raise Error , 'not all parameters set'
682+ raise Error ( 'not all parameters set' )
683683 return self ._nchannels , self ._sampwidth , self ._framerate , \
684684 self ._nframes , self ._comptype , self ._compname
685685
686686 def setmark (self , id , pos , name ):
687687 if id <= 0 :
688- raise Error , 'marker ID must be > 0'
688+ raise Error ( 'marker ID must be > 0' )
689689 if pos < 0 :
690- raise Error , 'marker position must be >= 0'
690+ raise Error ( 'marker position must be >= 0' )
691691 if type (name ) != type ('' ):
692- raise Error , 'marker name must be a string'
692+ raise Error ( 'marker name must be a string' )
693693 for i in range (len (self ._markers )):
694694 if id == self ._markers [i ][0 ]:
695695 self ._markers [i ] = id , pos , name
@@ -700,7 +700,7 @@ def getmark(self, id):
700700 for marker in self ._markers :
701701 if id == marker [0 ]:
702702 return marker
703- raise Error , 'marker %r does not exist' % (id ,)
703+ raise Error ( 'marker %r does not exist' % (id ,) )
704704
705705 def getmarkers (self ):
706706 if len (self ._markers ) == 0 :
@@ -770,18 +770,18 @@ def _ensure_header_written(self, datasize):
770770 if not self ._sampwidth :
771771 self ._sampwidth = 2
772772 if self ._sampwidth != 2 :
773- raise Error , 'sample width must be 2 when compressing with ULAW or ALAW'
773+ raise Error ( 'sample width must be 2 when compressing with ULAW or ALAW' )
774774 if self ._comptype == 'G722' :
775775 if not self ._sampwidth :
776776 self ._sampwidth = 2
777777 if self ._sampwidth != 2 :
778- raise Error , 'sample width must be 2 when compressing with G7.22 (ADPCM)'
778+ raise Error ( 'sample width must be 2 when compressing with G7.22 (ADPCM)' )
779779 if not self ._nchannels :
780- raise Error , '# channels not specified'
780+ raise Error ( '# channels not specified' )
781781 if not self ._sampwidth :
782- raise Error , 'sample width not specified'
782+ raise Error ( 'sample width not specified' )
783783 if not self ._framerate :
784- raise Error , 'sampling rate not specified'
784+ raise Error ( 'sampling rate not specified' )
785785 self ._write_header (datasize )
786786
787787 def _init_compression (self ):
@@ -798,13 +798,13 @@ def _init_compression(self):
798798 return
799799 except ImportError :
800800 pass
801- raise Error , 'cannot write compressed AIFF-C files'
801+ raise Error ( 'cannot write compressed AIFF-C files' )
802802 if self ._comptype == 'ULAW' :
803803 scheme = cl .G711_ULAW
804804 elif self ._comptype == 'ALAW' :
805805 scheme = cl .G711_ALAW
806806 else :
807- raise Error , 'unsupported compression type'
807+ raise Error ( 'unsupported compression type' )
808808 self ._comp = cl .OpenCompressor (scheme )
809809 params = [cl .ORIGINAL_FORMAT , 0 ,
810810 cl .BITS_PER_COMPONENT , self ._sampwidth * 8 ,
@@ -816,7 +816,7 @@ def _init_compression(self):
816816 elif self ._nchannels == 2 :
817817 params [1 ] = cl .STEREO_INTERLEAVED
818818 else :
819- raise Error , 'cannot compress more than 2 channels'
819+ raise Error ( 'cannot compress more than 2 channels' )
820820 self ._comp .SetParams (params )
821821 # the compressor produces a header which we ignore
822822 dummy = self ._comp .Compress (0 , '' )
@@ -930,7 +930,7 @@ def open(f, mode=None):
930930 elif mode in ('w' , 'wb' ):
931931 return Aifc_write (f )
932932 else :
933- raise Error , "mode must be 'r', 'rb', 'w', or 'wb'"
933+ raise Error ( "mode must be 'r', 'rb', 'w', or 'wb'" )
934934
935935openfp = open # B/W compatibility
936936
0 commit comments