diff options
author | Fred Drake <fdrake@acm.org> | 1999-06-22 21:23:23 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1999-06-22 21:23:23 (GMT) |
commit | 4316135a441aa7504c9feac1e706e5934c770c8b (patch) | |
tree | 9d7ea5a7a935845c56ef4b092d38584d60f250e6 | |
parent | 707f8e67b91896276a8fd1e1c0cf563642a34ecc (diff) | |
download | cpython-4316135a441aa7504c9feac1e706e5934c770c8b.zip cpython-4316135a441aa7504c9feac1e706e5934c770c8b.tar.gz cpython-4316135a441aa7504c9feac1e706e5934c770c8b.tar.bz2 |
Make the mode parameter to open() default in the same way as for wave.open().
-rw-r--r-- | Lib/aifc.py | 13 | ||||
-rw-r--r-- | Lib/sunau.py | 13 |
2 files changed, 18 insertions, 8 deletions
diff --git a/Lib/aifc.py b/Lib/aifc.py index c50bd79..a4d9616 100644 --- a/Lib/aifc.py +++ b/Lib/aifc.py @@ -920,13 +920,18 @@ class Aifc_write: _write_long(self._file, pos) _write_string(self._file, name) -def open(f, mode): - if mode == 'r': +def open(f, mode=None): + if mode is None: + if hasattr(f, 'mode'): + mode = f.mode + else: + mode = 'rb' + if mode in ('r', 'rb'): return Aifc_read(f) - elif mode == 'w': + elif mode in ('w', 'wb'): return Aifc_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 diff --git a/Lib/sunau.py b/Lib/sunau.py index b49a5da..0ba7dc9 100644 --- a/Lib/sunau.py +++ b/Lib/sunau.py @@ -456,12 +456,17 @@ class Au_write: self._datalength = self._datawritten self._file.seek(0, 2) -def open(f, mode): - if mode == 'r': +def open(f, mode=None): + if mode is None: + if hasattr(f, 'mode'): + mode = f.mode + else: + mode = 'rb' + if mode in ('r', 'rb'): return Au_read(f) - elif mode == 'w': + elif mode in ('w', 'wb'): return Au_write(f) else: - raise Error, "mode must be 'r' or 'w'" + raise Error, "mode must be 'r', 'rb', 'w', or 'wb'" openfp = open |