summaryrefslogtreecommitdiffstats
path: root/Lib/wave.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1998-04-16 16:44:33 (GMT)
committerFred Drake <fdrake@acm.org>1998-04-16 16:44:33 (GMT)
commitac36c6403ff78b5f48c3dde7626806de87cfff0c (patch)
tree25ca32eb015812d897b3c8b02fc9e051b794bd90 /Lib/wave.py
parentbf88c3830e3a7d31022039fa265896aec90db61e (diff)
downloadcpython-ac36c6403ff78b5f48c3dde7626806de87cfff0c.zip
cpython-ac36c6403ff78b5f48c3dde7626806de87cfff0c.tar.gz
cpython-ac36c6403ff78b5f48c3dde7626806de87cfff0c.tar.bz2
Open wave files in binary mode.
Accept 'rb' and 'wb' as well as 'r' and 'w' as the mode parameter to open().
Diffstat (limited to 'Lib/wave.py')
-rw-r--r--Lib/wave.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/wave.py b/Lib/wave.py
index bba4e87..365bbf9 100644
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -230,7 +230,7 @@ class Wave_read:
def __init__(self, f):
if type(f) == type(''):
- f = __builtin__.open(f, 'r')
+ f = __builtin__.open(f, 'rb')
# else, assume it is an open file object already
self.initfp(f)
@@ -368,7 +368,7 @@ class Wave_write:
def __init__(self, f):
if type(f) == type(''):
- f = __builtin__.open(f, 'w')
+ f = __builtin__.open(f, 'wb')
self.initfp(f)
def initfp(self, file):
@@ -549,11 +549,11 @@ class Wave_write:
self._datalength = self._datawritten
def open(f, mode):
- if mode == 'r':
+ if mode in ('r', 'rb'):
return Wave_read(f)
- elif mode == 'w':
+ elif mode in ('w', 'wb'):
return Wave_write(f)
else:
- raise Error, "mode must be 'r' or 'w'"
+ raise Error, "mode must be 'r', 'rb', 'w', or 'wb'"
openfp = open # B/W compatibility