diff options
author | Collin Winter <collinw@gmail.com> | 2007-08-30 01:19:48 +0000 |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2007-08-30 01:19:48 +0000 |
commit | ce36ad8a467d914eb5c91f33835b9eaea18ee93b (patch) | |
tree | 05bf654f3359e20b455dc300bd860bba5d291c8d /Lib/wave.py | |
parent | Copying the email package back, despite its failings. (diff) | |
download | cpython-ce36ad8a467d914eb5c91f33835b9eaea18ee93b.tar.gz cpython-ce36ad8a467d914eb5c91f33835b9eaea18ee93b.tar.bz2 cpython-ce36ad8a467d914eb5c91f33835b9eaea18ee93b.zip |
Raise statement normalization in Lib/.
Diffstat (limited to 'Lib/wave.py')
-rw-r--r-- | Lib/wave.py | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/Lib/wave.py b/Lib/wave.py index 42bf8bfe8ed..4fc1bf1851c 100644 --- a/Lib/wave.py +++ b/Lib/wave.py @@ -127,9 +127,9 @@ class Wave_read: self._soundpos = 0 self._file = Chunk(file, bigendian = 0) if self._file.getname() != b'RIFF': - raise Error, 'file does not start with RIFF id' + raise Error('file does not start with RIFF id') if self._file.read(4) != b'WAVE': - raise Error, 'not a WAVE file' + raise Error('not a WAVE file') self._fmt_chunk_read = 0 self._data_chunk = None while 1: @@ -144,14 +144,14 @@ class Wave_read: self._fmt_chunk_read = 1 elif chunkname == b'data': if not self._fmt_chunk_read: - raise Error, 'data chunk before fmt chunk' + raise Error('data chunk before fmt chunk') self._data_chunk = chunk self._nframes = chunk.chunksize // self._framesize self._data_seek_needed = 0 break chunk.skip() if not self._fmt_chunk_read or not self._data_chunk: - raise Error, 'fmt chunk and/or data chunk missing' + raise Error('fmt chunk and/or data chunk missing') def __init__(self, f): self._i_opened_the_file = None @@ -214,11 +214,11 @@ class Wave_read: return None def getmark(self, id): - raise Error, 'no marks' + raise Error('no marks') def setpos(self, pos): if pos < 0 or pos > self._nframes: - raise Error, 'position not in range' + raise Error('position not in range') self._soundpos = pos self._data_seek_needed = 1 @@ -266,7 +266,7 @@ class Wave_read: sampwidth = struct.unpack_from('<h', chunk.read(2))[0] self._sampwidth = (sampwidth + 7) // 8 else: - raise Error, 'unknown format: %r' % (wFormatTag,) + raise Error('unknown format: %r' % (wFormatTag,)) self._framesize = self._nchannels * self._sampwidth self._comptype = 'NONE' self._compname = 'not compressed' @@ -328,43 +328,43 @@ class Wave_write: # def setnchannels(self, nchannels): if self._datawritten: - raise Error, 'cannot change parameters after starting to write' + raise Error('cannot change parameters after starting to write') if nchannels < 1: - raise Error, 'bad # of channels' + raise Error('bad # of channels') self._nchannels = nchannels def getnchannels(self): if not self._nchannels: - raise Error, 'number of channels not set' + raise Error('number of channels not set') return self._nchannels def setsampwidth(self, sampwidth): if self._datawritten: - raise Error, 'cannot change parameters after starting to write' + raise Error('cannot change parameters after starting to write') if sampwidth < 1 or sampwidth > 4: - raise Error, 'bad sample width' + raise Error('bad sample width') self._sampwidth = sampwidth def getsampwidth(self): if not self._sampwidth: - raise Error, 'sample width not set' + raise Error('sample width not set') return self._sampwidth def setframerate(self, framerate): if self._datawritten: - raise Error, 'cannot change parameters after starting to write' + raise Error('cannot change parameters after starting to write') if framerate <= 0: - raise Error, 'bad frame rate' + raise Error('bad frame rate') self._framerate = framerate def getframerate(self): if not self._framerate: - raise Error, 'frame rate not set' + raise Error('frame rate not set') return self._framerate def setnframes(self, nframes): if self._datawritten: - raise Error, 'cannot change parameters after starting to write' + raise Error('cannot change parameters after starting to write') self._nframes = nframes def getnframes(self): @@ -372,9 +372,9 @@ class Wave_write: def setcomptype(self, comptype, compname): if self._datawritten: - raise Error, 'cannot change parameters after starting to write' + raise Error('cannot change parameters after starting to write') if comptype not in ('NONE',): - raise Error, 'unsupported compression type' + raise Error('unsupported compression type') self._comptype = comptype self._compname = compname @@ -387,7 +387,7 @@ class Wave_write: def setparams(self, params): nchannels, sampwidth, framerate, nframes, comptype, compname = params if self._datawritten: - raise Error, 'cannot change parameters after starting to write' + raise Error('cannot change parameters after starting to write') self.setnchannels(nchannels) self.setsampwidth(sampwidth) self.setframerate(framerate) @@ -396,15 +396,15 @@ class Wave_write: def getparams(self): if not self._nchannels or not self._sampwidth or not self._framerate: - raise Error, 'not all parameters set' + raise Error('not all parameters set') return self._nchannels, self._sampwidth, self._framerate, \ self._nframes, self._comptype, self._compname def setmark(self, id, pos, name): - raise Error, 'setmark() not supported' + raise Error('setmark() not supported') def getmark(self, id): - raise Error, 'no marks' + raise Error('no marks') def getmarkers(self): return None @@ -451,11 +451,11 @@ class Wave_write: def _ensure_header_written(self, datasize): if not self._datawritten: if not self._nchannels: - raise Error, '# channels not specified' + raise Error('# channels not specified') if not self._sampwidth: - raise Error, 'sample width not specified' + raise Error('sample width not specified') if not self._framerate: - raise Error, 'sampling rate not specified' + raise Error('sampling rate not specified') self._write_header(datasize) def _write_header(self, initlength): @@ -495,6 +495,6 @@ def open(f, mode=None): elif mode in ('w', 'wb'): return Wave_write(f) else: - raise Error, "mode must be 'r', 'rb', 'w', or 'wb'" + raise Error("mode must be 'r', 'rb', 'w', or 'wb'") openfp = open # B/W compatibility |