diff --git a/soundfile.py b/soundfile.py index cddf40a..84f915b 100644 --- a/soundfile.py +++ b/soundfile.py @@ -331,9 +331,11 @@ def read(file, frames=-1, start=0, stop=None, dtype='float64', always_2d=True, def write(data, file, samplerate, subtype=None, endian=None, format=None, - closefd=True, exclusive_creation=True): + closefd=True): """Write data to a sound file. + .. note:: If `file` exists, it will be truncated and overwritten! + Parameters ---------- data : array_like @@ -356,9 +358,6 @@ def write(data, file, samplerate, subtype=None, endian=None, format=None, Other Parameters ---------------- - exclusive_creation : bool - If ``True`` (the default), the file is opened with ``mode='x'``. - Otherwise, it is opened with ``mode='w'``. format, endian, closefd See :class:`SoundFile`. @@ -377,8 +376,7 @@ def write(data, file, samplerate, subtype=None, endian=None, format=None, channels = 1 else: channels = data.shape[1] - mode = 'x' if exclusive_creation else 'w' - with SoundFile(file, mode, samplerate, channels, + with SoundFile(file, 'w', samplerate, channels, subtype, endian, format, closefd) as f: f.write(data) diff --git a/tests/test_argspec.py b/tests/test_argspec.py index b0d1cc4..d5b6029 100644 --- a/tests/test_argspec.py +++ b/tests/test_argspec.py @@ -44,7 +44,6 @@ def test_read_defaults(): def test_write_defaults(): write_defaults = defaults(write_function) - del write_defaults['exclusive_creation'] init_defaults = defaults(init) # Same default values as SoundFile.__init__() diff --git a/tests/test_pysoundfile.py b/tests/test_pysoundfile.py index 04101d5..731d622 100644 --- a/tests/test_pysoundfile.py +++ b/tests/test_pysoundfile.py @@ -214,12 +214,6 @@ def test_write_with_unknown_extension(filename): assert "file extension" in str(excinfo.value) -def test_write_with_exclusive_creation(): - with pytest.raises(OSError) as excinfo: - sf.write(data_mono, filename_mono, 44100) - assert "File exists" in str(excinfo.value) - - # ----------------------------------------------------------------------------- # Test blocks() function # -----------------------------------------------------------------------------